Problem with parsing xml file using php. Url address doesn't contain .xml extension

Brad8N

New Member
Hey guys. I'm trying to parse xml file in order to extract some data from it and display it on the website. However, when I'm using url which doesn't end with \[code\].xml\[/code\] extension I can't run a \[code\]foreach\[/code\] loop on the result. In other words when I'm using this kind of url:\[code\]$url = http://www.example.com/some_xml_file.xml\[/code\]I can run a a foreach loop on it and it works like charm. But this time around I have to deal with this type of url:\[code\]$url = http://www.example.com/?some_var=something&some=something\[/code\]So you can clearly see that it doesn't contain \[code\].xml\[/code\] extension. It returns nicely parsed result but I can't get the foreach loop to work on this result and therefore I can't extract any data from it. Could you help me with this one?Example of what I'm doing:\[code\]$url = 'http://www.example.com/?some_var=something&some=somethinge'; $sx = simplexml_load_file($url); foreach ($sx->response as $row) { echo $row['status']; }\[/code\]And this is the result of var_dump($sx):\[code\]object(SimpleXMLElement)#334 (2) { ["@attributes"]=> array(2) { ["status"]=> string(2) "ok" ["version"]=> string(3) "1.0" } ["events"]=> object(SimpleXMLElement)#333 (2) { ["@attributes"]=> array(3) { ["resultCount"]=> string(1) "1" ["pageSize"]=> string(2) "15" ["pageIndex"]=> string(1) "0" } ["event"]=> object(SimpleXMLElement)#338 (10) { ["@attributes"]=> array(1) { ["id"]=> string(6) "180085" } ["name"]=> string(27) "Lady Gaga Monster Ball Tour" ["doordatetime"]=> string(19) "2010-11-01T18:30:00" ["tickets"]=> object(SimpleXMLElement)#337 (1) { ["ticket"]=> array(5) { [0]=> object(SimpleXMLElement)#339 (7) { ["@attributes"]=> array(1) { ["id"]=> string(6) "307902" } ["price"]=> string(7) "
 
Back
Top