simple xml getName does not work

charanzia

New Member
I try to get the element name of the xml. I use getName() function. But I do not know why it always goes wrong, it gets error on that page.\[code\] $xml=filePath::$xml; //guide to the xml file //use simple xml to get the attributes $xmldoc=simplexml_load_file($xml); //get the children foreach($xmldoc->children() as $child) { foreach($child->attributes() as $a=>$b) { echo $b;//this statement works correctly } echo $child->getName();//this statement does not work, and it leads to the error. }\[/code\]why?The xml file like:root collection id="new1" slash collection collection id="new2" slash collectionslash rootThe correctly output should be: new1 collection new2 collection. But the "collection" cannot be print out.
 
Back
Top