I have been tasked with parsing data returned from one of our providers. The XML has two attribute arrays and I need to retrieve information from the second. Following is the data I am using as displayed by print_r.
SimpleXMLElement Object
(
[@attributes] => Array
(
[version] => 2.0
)
[channel] => SimpleXMLElement Object
(
[title] => Content Mix for Weather-in-Pictures
[link] => http://www.abc123.com/
[description] => abc123 Content Server
[docs] => http://www.rssboard.org/rss-specification
[generator] => abc123 Content Server
[lastBuildDate] => Wed, 22 Apr 2015 19:36:51 GMT
[ttl] => 5
[item] => SimpleXMLElement Object
(
[title] => Weather in Pictures
[guid] => mk1pL9MkC2f3tz71QgUwyA2
[pubDate] => Wed, 22 Apr 2015 19:36:51 GMT
[enclosure] => SimpleXMLElement Object
(
[@attributes] => Array
(
[length] => 204800
[type] => image/jpeg
[url] => http://abc123.com
)
)
)
)
)
The url is what I need to retrieve. I have a feeling this is going to be one of those "DUH!" moments when someone points out what I need to do.
current ($xml(attributes)) // returns only version.
$xml->attributes()->url; // does not return anything.