How do I parse this XML with PHP

pikeypete.

New Member
Normally the XML files I have to parse are like this:\[code\]<row id="1"> <title>widget<title> <color>blue<color> <price>five<price></row>\[/code\]Which I would then parse like this:\[code\]$xmlstr_widget = file_get_contents($my_xml_feed);$feed_widget = new SimpleXMLElement($xmlstr_widget);foreach($feed_widget as $name) { $title = $name->title; $color = $name->color; $price = $price->price; }\[/code\]Works great! But now I have xml in a bit different format and I am a little stumped since I don't have a whole lot of xml parsing experience:\[code\]<Widget Title="large" Color="blue" Price="five"/><Widget Title="small" Color="red" Price="ten"/>\[/code\]How do I drill into that a little further and get it parsed properly? I have tried a few things but no success.So the problem is when I try something like below with the different xml feed, I cannot echo any results. \[code\]foreach($feed_widget as $name) { $title = $name->title; $color = $name->color; $price = $price->price; }\[/code\]
 
Back
Top