Using simplexml_load_file(), if I’m parsing out XML and I get the following for image…
SimpleXMLElement Object
(
[@attributes] => Array
(
[size] => small
)
[0] => http://userserve-ak.last.fm/serve/34s/72903330.png
)
SimpleXMLElement Object
(
[@attributes] => Array
(
[size] => medium
)
[0] => http://userserve-ak.last.fm/serve/64s/72903330.png
) // ... etc
My question is…how do I get to the image URL at array[0]? I know how to access my ‘size’ attribute with the attributes() method. But I can’t seem to echo out the URL. I’ve tried
$img = $xml -> album -> image[0]; <----i see nothing
$img = $xml -> album -> image -> 0; <-----i get a 500 error
Any help would be greatly appreciated. Thanks!
-Bob
or
Should do the trick.
You could also try