我的任务是解析从我们的某个提供商返回的数据。 XML有两个属性数组,我需要从第二个中检索信息。以下是我正在使用的数据,如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
)
)
)
)
)
我需要检索网址。我有一种感觉,这将成为其中一个" DUH!"有人指出我需要做什么的时刻。
current ($xml(attributes)) // returns only version.
$xml->attributes()->url; // does not return anything.