PHP - Simple XML - Nested Hierarchy

galleanginler

New Member
I have been using PHP's simple XML function to work with an XML file.The below code works fine for a simple XML hierarchy: \[code\]<?php$xml = simplexml_load_file("test.xml");echo $xml->getName() . "<br />";foreach($xml->children() as $child) { echo $child->getName() . ": " . $child . "<br />"; }?>\[/code\]This assumes the structure of the XML document is as follows:\[code\]<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>\[/code\]However, if I had a more complex structure within my XML document- the contents simply is not output. A more complex XML example is shown below:\[code\]<note><noteproperties><notetype>TEST</notetype></noteproperties><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>\[/code\]I need to process XML files that have an indefinite depth - can anyone suggest a method?
 
Back
Top