I am using the code bellow to fetch results from my wordpress feed.
It’s woorking great but i have an issue with one record while fetching it.
My code to fetch the feed (http://www.example.com/feed/) is:
<?php
$rss = new DOMDocument();
$rss->load('http://www.example.com/category/celeb-news/feed/');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$title = $node->getElementsByTagName('title')->item(0)->nodeValue;
$desc = $node->getElementsByTagName('description')->item(0)->nodeValue;
$link = $node->getElementsByTagName('link')->item(0)->nodeValue;
//$date = $node->getElementsByTagName('pubDate')->item(0)->nodeValue;
//$full = $node->getElementsByTagName('content:encoded')->item(0)->nodeValue;
echo '<div style="width:90%; padding-bottom:10px; margin-bottom:10px; float: left; border-bottom:1px solid #000; margin-left:5%; margin-right:5%;">';
echo '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
echo '<p>'.$desc.'</p>';
echo '<p>'.$full.'</p>';
echo '</div>';
}
?>
The feed structure is like this:
<item>
<tite></title>
<description></description>
<link></link>
<pubDate></pubDate>
<content:encoded><![CDATA[ full content here ]]></content:encoded>
<comments></comments>
</item>
The problem is when i am using this code $full = $node->getElementsByTagName('content:encoded')->item(0)->nodeValue;
to fetch i get this error: Notice: Trying to get property of non-object in myfile at line x
Any ideas?