try function load_string down there: class XmlArray { public function load_dom ($xml) { $node=simplexml_import_dom($xml); //print "Before node reading\n"; return $this->add_node($node); } public function &load_string ($s) { $node=simplexml_load_string($s); //print "Before node reading\n"; $ret = $this->add_node($node); return $ret; } private function add_node ($node, &$parent=null, $namespace='', $recursive=false) { $namespaces = $node->getNameSpaces(true); $r['name']=$node->getName(); //$content="$node"; $content=htmlspecialchars((string) $node); if ($namespace) $r['namespace']=$namespace; if (strlen($content)) $r['content']=$content; foreach ($namespaces as $pre=>$ns) { foreach ($node->children($ns) as $k=>$v) { $this->add_node($v, $r['children'], $pre, true); } foreach ($node->attributes($ns) as $k=>$v) { $r['attributes'][$k]="$pre:$v"; } } foreach ($node->children() as $k=>$v) { $this->add_node($v, $r['children'], '', true); } foreach ($node->attributes() as $k=>$v) { $r['attributes'][$k]="$v"; } $parent[]=&$r; return $parent[0]; } }
... View more