如何使用simplexml讀取iTunes RSS中的機箱url標記?simplexml閱讀enclousure html標記
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;
}
rss-> channel-> item-> enclosure-> attributes() - > url我認爲應該得到的網址。 – 2014-08-29 13:49:28
@Matt:是的!這是正確的答案。謝謝 – Nrc 2014-08-29 13:58:04
作爲回答加入 – 2014-08-29 13:59:50