OK so I have very limited PHP coding knowledge and what I have been able to put together I usually find from various sources online and more-or-less manipulate that code to match what I’m trying to do. Case in point I needed to pull a list of items from an iTunes podcast feed and display into a table format on a webpage. I was able to find the basic code to pull most of the elements I needed and was able to manipulate that in order to get it to display in an table. My problem is whenever I want to pull an element that has the itunes: prefix. I receive no data from the request. So I’m not sue what I’m doing wrong.
So in the following code everything works exactly how I want it to except the lines where I reference ‘itunes:duration’, ‘dura’ and $duration. Currently that column is showing as empty no data at all however the feed does in fact contain that element.
Can anyone fill me in on what I’m missing here?
[php]
<?php $rss = new DOMDocument(); $rss->load('http://tulsachurchofgod.sermon.tv/rss/TCOG_2012_Archives/audio'); $feed = array(); $limit = 0; foreach ($rss->getElementsByTagName('item') as $node) { $limit = $limit+1; $item = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'creat' => $node->getElementsByTagName('creator')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('guid')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue, 'dura' => $node->getElementsByTagName('itunes:duration')->item(0)->nodeValue, ); array_push($feed, $item); } echo ''.$title.'
';
?>
DATE | SPEAKER | TITLE | TIME |
<?=$date;?> | <?=$creator;?> | <? echo ''.$title.'';?> | <?=$duration;?> |