mtorbin Posted December 22, 2008 Share Posted December 22, 2008 Hey folks, I have xml similar to the following: <masterNode> <node> <group> <item> <attribute01></attribute01> <attribute02></attribute02> <attribute03></attribute03> <attribute04></attribute04> <attribute05></attribute05> <attribute06></attribute06> </item> <item> <attribute01></attribute01> <attribute02></attribute02> <attribute03></attribute03> <attribute04></attribute04> <attribute05></attribute05> <attribute06></attribute06> </item> <item> <attribute01></attribute01> <attribute02></attribute02> <attribute03></attribute03> <attribute04></attribute04> <attribute05></attribute05> <attribute06></attribute06> </item> <group> </node> </masterNode> I'd like to create a loop that says "for each <item> found..." but I'm not sure what syntax to use. Is this an xPath issue or something else? Suggestions are much appreciated. Thanks, - MT Link to comment https://forums.phpfreaks.com/topic/138059-parsing-xml-with-simplexml/ Share on other sites More sharing options...
rhodesa Posted December 22, 2008 Share Posted December 22, 2008 as long as there is only one group: foreach($xml->node->group->item as $item){ print (string)$item->attribute01; } Link to comment https://forums.phpfreaks.com/topic/138059-parsing-xml-with-simplexml/#findComment-721618 Share on other sites More sharing options...
mtorbin Posted December 22, 2008 Author Share Posted December 22, 2008 That works perfectly. Thanks Aaron! Link to comment https://forums.phpfreaks.com/topic/138059-parsing-xml-with-simplexml/#findComment-721671 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.