0
votes

I have read about a dozen posts on this topic here on SO and all of them refer to the whitespace issue, which I don't have, and feed validator agrees my feed is okay (http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fgearmunk.com%2Fblog%2Ffeed%2F)

I am using the following code to parse the rss:

<?php
$rss = new DOMDocument();
$rss->load('http:/gearmunk.com/blog/feed/');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array ( 
'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,
);
array_push($feed, $item);
}
$limit = 3;
for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
$link = $feed[$x]['link'];
$description = $feed[$x]['desc'];
$date = date('l F d, Y', strtotime($feed[$x]['date']));
echo '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
echo '<small><em>Posted on '.$date.'</em></small></p>';
echo '<p>'.$description.'</p>';
}
?>

but if you look at http://gearmunk.com/index3.php you will see, on the right, it lists 3 bad dates and no rss data. If I put in another feed URL it works fine, and if I put my rss feed into Google reader it works just fine. I'm hoping there is something stupid simple I'm missing. Can someone help?

thanks, Erik

MORE INFORMATION:

I started to focus in on it being a wordpress problem, so I tried some other wordpress RSS feeds. One from CNN works fine (http://religion.blogs.cnn.com/feed/), however, one from BoingBoing (also a WP site) doesn't work: http://boingboing.net/feed.

I am not getting the XML Parse error normally associated with the whitespace issue, so I don't think that is it.

Erik

2

2 Answers

3
votes

Try changing

$rss->load('http:/gearmunk.com/blog/feed/');

To the following ( note the extra / )

$rss->load('http://gearmunk.com/blog/feed/');

Code appeared to run as expected with that change.

0
votes

I know this is an old question but I came across it trying to fix my own WordPress RSS feed issue. In my case I was missing the PHP XML extension.

So I ran apt-get install php7.0-xml (I'm running PHP v7.0 on Ubuntu, check your php version), restarted my server and it totally fixed my problem!

For CentOS / Fedora / Red Hat on PHP 7:

yum install php70w-xml

Hope this helps somebody!