如何使用simplexml读取iTunes RSS中的enclosure url标记?
FEED:
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
<item>
<itunes:subtitle> subtitle </itunes:subtitle>
<enclosure url="http://www.myWe/mySound.mp3" length="624557" type="audio/mp3"/>
</item>
</channel>
</rss>
PHP:
foreach ($feed->channel->item as $item) {
$iTunes_item = $item->children('http://www.itunes.com/dtds/podcast-1.0.dtd');
$item_subtitle = $item->subtitle->attributes();
$item_url = $iTunes_item->enclosure->attributes('url'); // enclosure url
echo $item_subtitle;
echo $item_url;
}
答案 0 :(得分:6)
访问网址使用;
rss->channel->item->enclosure->attributes()->url
尝试使用这个来获取副标题;
$namespaces = $item->getNameSpaces(true);
$nodes = $item->children($namespaces['itunes']);
echo $nodes->subtitle;