コード例 #1
0
 public function unserialize($data)
 {
     if ($data) {
         return ncXML2Array::createArray($data);
     }
     return '';
 }
コード例 #2
0
 /**
  * Convert an XML to Array
  * @param string $node_name - name of the root node to be converted
  * @param array $arr - aray to be converterd
  * @return DOMDocument
  */
 public static function &createArray($input_xml)
 {
     $xml = self::getXMLRoot();
     if (is_string($input_xml)) {
         $parsed = $xml->loadXML($input_xml);
         if (!$parsed) {
             throw new Exception('[ncXML2Array] Error parsing the XML string.');
         }
     } else {
         if (get_class($input_xml) != 'DOMDocument') {
             throw new Exception('[ncXML2Array] The input XML object should be of type: DOMDocument.');
         }
         $xml = self::$xml = $input_xml;
     }
     $array[$xml->documentElement->tagName] = self::convert($xml->documentElement);
     self::$xml = null;
     // clear the xml node in the class for 2nd time use.
     return $array;
 }