Retrieving RSS feed with tag <content:encoded>
In <content:encoded>
, content
is the namespace and encoded
is the tag name.
You have to use SimpleXMLElement::children
. See the output of
var_dump($entry->children("content", true));
The Tag name here is "encoded".Try this:
$url = 'put_your_feed_URL'; $rss = new DOMDocument(); $rss->load($url); $feed = array(); foreach ($rss->getElementsByTagName('item') as $node) { $item = array ( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'pubDate' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue, 'description' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'content' => $node->getElementsByTagName('encoded')->item(0)->nodeValue ); array_push($feed, $item); }
I'll suggest you the following code:
function getFeed($feed_url) { $feeds = file_get_contents($feed_url); $feeds = str_replace("<content:encoded>","<contentEncoded>",$feeds); $feeds = str_replace("</content:encoded>","</contentEncoded>",$feeds); $rss = simplexml_load_string($feeds); echo "<ul>"; foreach($x->channel->item as $entry) { echo "<li><a href='$entry->link' title='$entry->title'>" . $entry->title . "</a></li>"; echo "<li>$entry->contentEncoded</li>"; echo "</ul>"; }
Hope this works for you.