0

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 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

8 Comments

Conrad, I did change that and I still get the same problem: <?php $rss = new DOMDocument(); $rss->load('gearmunk.com/blog/feed/'); $feed = array(); gearmunk.com/index3.php
Please try again, that's the only change I made, and I get what appears to be expected output. I've copied the code with just that one change to dev.rcs.us/stackoverflow.com/14390011
Conrad. Very interesting. It works on your server but not on mine (the same server hosting the WP blog). I confirmed (more than once) that http:// is in there. We now can safely say it is something on my server causing the problem. I will keep digging, thanks so much!
I even created a new file to make sure it wasn't other php messing with it, same result. (gearmunk.com/feedy.php)
It might be worth contacting your hosting provider. It might an issue with the lookup of DNS on a record within their environment. If you have full access to the server, a modification to /etc/resolve.conf would likely resolve that, if it were in fact the case.
|
0

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.