--TEST-- SimpleXML: iteration through subnodes and attributes --SKIPIF-- --FILE-- Text1 Text2 Text3 EOF; $xml1 =<< EOF; function traverse_xml($pad,$xml) { foreach($xml->children() as $name => $node) { echo $pad."<$name"; foreach($node->attributes() as $attr => $value) { echo " $attr=\"$value\""; } echo ">\n"; traverse_xml($pad." ",$node); echo $pad."\n"; } } traverse_xml("",simplexml_load_string($xml)); echo "----------\n"; traverse_xml("",simplexml_load_string($xml1)); echo "---Done---\n"; ?> --EXPECT-- ---------- ---Done---