I’m having some trouble in getting information from my itunes XML feed which you can peek at here: http://c3carlingford.org.au/podcast/C3CiTunesFeed.xml
I need to get the information from each of the inner <item> tags. An example of one of these is as follows:
<item>
<title>What to do when a viper bites you</title>
<itunes:subtitle/>
<itunes:summary/>
<!-- 4000 Characters Max ******** -->
<itunes:author>Ps. Phil Buechler</itunes:author>
<itunes:image href="http://www.c3carlingford.org.au/podcast/itunes_cover_art.jpg"/>
<enclosure url="http://www.ccccarlingford.org.au/podcast/C3C-20120722PM.mp3" length="14158931" type="audio/mpeg"/>
<guid isPermaLink="false">61bc701c-b374-40ea-bc36-6c1cdaae8042</guid>
<pubDate>Sun, 22 Jul 2012 19:30:00 +1100</pubDate>
<itunes:duration>40:01</itunes:duration>
<itunes:keywords>
Worship, Reach, Build, Holy Spirit, Worship, C3 Carlingford
</itunes:keywords>
</item>
Now i have had some success!
I have been able to get the title out of it all:
<?php
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->load('http://c3carlingford.org.au/podcast/C3CiTunesFeed.xml');
$items = $dom->getElementsByTagName('item');
foreach($items as $item){
$title = $item->getElementsByTagName('title')->item(0)->nodeValue;
echo $title . '<br />';
};
?>
But I can’t seem to get anything else out… I’m new to all this!
So What I need to get out includes:
- The
<itunes:author>value. - The url attribute value from the
<enclosure>tag
Would someone help me getting these two values out?
You can use
DOMXPathto do this and make your life a lot easier:You can see from the demo that this will output: