我有这个XML Feed:
<item>
<title>Title</title>
<media:group>
<media:content url="http://example.it/image.jpg" type="image/jpeg">
<media:thumbail url="http://example.it/image.jpg" type="image/png"/>
<media:credit>Credit</media:credit>
</media:content>
<media:content url="http://example.it/image2.jpg" type="image/jpeg">
<media:thumbail url="http://example.it/image2.jpg" type="image/png"/>
<media:credit>Credit2</media:credit>
</media:content>
</media:group>
</item>
这是我读取它的PHP代码:
$rss = new SimpleXMLElement($url);
foreach ($rss->channel->item as $item) {
$title = $item->title;
}
阅读没问题&#34;标题&#34;项目,但我怎样才能阅读&#34; url&#34;,&#34; thumbnail&#34;,&#34; credit&#34;对于每种媒体:内容?
------- -------解决
$rss = new SimpleXMLElement($url);
foreach ($rss->channel->item as $item) {
$title = $item->title;
$gallerie = $item->children('http://search.yahoo.com/mrss/')->group->content;
foreach($gallerie as $g) {
echo $g->attributes()['url'] ."<br/>";
}
}