Reading RSS feed using JavaScript

I have an idea in mind to build a simple introductory website for myself and one of the things I wanted on the front page of that website was a RSS feed type of thing on the front page. This way I could link to this existing blog link and not have to deal with moving my blog to a new domain, etc.

Anyway, surprisingly, few solutions exist to read a blog’s feed(which is XML) and do things with it using JavaScript.

Things I tried:

1. Looked at WordPress to see if it provided a JavaScript API. It doesn’t.

2. Since I use Dojo for all my JavaScript programming, I looked at dojo.script.io.get to make a cross domain Ajax call and then use the response to extract what I want out of the feed.
Turns out dojo.script.io.get only can handle JSON responses. So this fails as a solution.

3. YUI combined with YQL is a possible solution. I could use YQL to query the feed and then use YUI to read that result. Not bad. Definitely a solution.

4. Then I found JSonduit. Seems to be written just to solve my problem 🙂 How does this work?

You include this JS file:

And then, call the following function:

JSonduit.feed.load(feedId, 0, function(data) {
if (data.error) {
alert("Feed Error: " + data.error.error + " : " + data.error.desc);
}
else {
//do something with the result
}
});

Read up here for more information about this and some sample code.

Advertisements

One thought on “Reading RSS feed using JavaScript

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s