How to parse the <enclosure> tage in RSS feed?
Posted: Tue Jun 09, 2009 1:42 am
I found this code to help me get started in parsing RSS feed and extract the basic information I wanted. However, I have tried and tried and tried to parse the <enclosure> tag to extract the url, length and type but no success. What do you suggest I should add to the code below to get the enclosure information?
I appreciate your help.
Code: Select all
$doc = new DOMDocument();
$doc->load('http://davebender.podbean.com/feed/');
$arrFeeds = array();
foreach ($doc->getElementsByTagName('item') as $node) {
$itemRSS = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue
);
array_push($arrFeeds, $itemRSS);