示例#1
0
 function export($data_type = false, $dataSets = false)
 {
     //get xml into array
     if ($dataSets) {
         include_once 'xml.class.php';
         $xml = new EF_XML_Helper();
         header('Content-Type: application/octet-stream');
         echo $xml->toXML($dataSets, $data_type);
         exit;
     } else {
         return false;
     }
 }
示例#2
0
 /**
  * Convert an XML document to a multi dimensional array
  * Pass in an XML document (or SimpleXMLElement object) and this recrusively loops through and builds a representative array
  *
  * @param string $xml - XML document - can optionally be a SimpleXMLElement object
  * @return array ARRAY
  */
 public static function toArray($xml)
 {
     if (is_string($xml)) {
         $xml = new SimpleXMLElement($xml);
     }
     $children = $xml->children();
     if (!$children) {
         return (string) $xml;
     }
     $arr = array();
     foreach ($children as $key => $node) {
         $node = EF_XML_Helper::toArray($node);
         if (is_string($node)) {
             $node = html_entity_decode($node, ENT_QUOTES);
         }
         // support for 'anon' non-associative arrays
         if ($key == 'anon') {
             $key = count($arr);
         }
         // if the node is already set, put it into an array
         if (isset($arr[$key])) {
             if (!is_array($arr[$key]) || !isset($arr[$key][0]) || $arr[$key][0] == null) {
                 $arr[$key] = array($arr[$key]);
             }
             $arr[$key][] = $node;
         } else {
             $arr[$key] = $node;
         }
     }
     global $logger;
     return $arr;
 }