How to parse rss from a php page, using jQuery/jFeed?

Posted by ricebowl on Stack Overflow See other posts from Stack Overflow or by ricebowl
Published on 2010-03-12T17:01:02Z Indexed on 2010/03/12 17:07 UTC
Read the original article Hit count: 336

Filed under:
|
|
|

I'm trying to fumble my way through parsing rss sensibly, using jQuery and jFeed.

Because of the same origin policy I'm pulling the BBC's health news feed into a local page (http://www.davidrhysthomas.co.uk/play/proxy.php).

Originally this was just the same proxy.php script as available in the jFeed download package, but due to my host's disabling allow_url_fopen() I've amended the php to the following:

$url = "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/health/rss.xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);

echo "$data";
curl_close($ch);

Which seems to generate the same/comparable contents as the original fopen on my local machine.

Now that seems to be working, I'm looking at setting the jFeed script up to work with the page and, to my embarrassment, don't see how.

I understand that, at the least, this should work:

jQuery.getFeed({
   url: 'http://www.davidrhysthomas.co.uk/play/proxy.php',
   success: function(feed) {
      alert(feed.title);
   }
});

...but, as I'm sure you anticipate, it doesn't. What non-output there is, is available for your perusal here: http://www.davidrhysthomas.co.uk/play/exampleTest.html. And I honestly don't have a clue what to do about it.

If anyone could offer some pointers, tips, hints, or, at a pinch, a quick slap around the cheeks and a 'pull yourself together!' it'd be much appreciated...

Thanks in advance =)

© Stack Overflow or respective owner

Related posts about rss

Related posts about php