For a while now I've used the Google Feed API to parse RSS feeds in JavaScript. It did a good job of converting various RSS flavors into a simple array of entries you could easily work with. Unfortunately, Google has deprecated the API and while it still worked the last time I used it, I would strongly recommend folks migrate their apps away from it as soon as possible. While this makes me sad, you have to move on.

So what kind of options do you have?
Parsing Manually
So remember that RSS is just XML, and XML is just a string, and string parsing is easy, right? Of course, there are 2 major flavors of RSS, and multiple versions of both flavors, but if you're just parsing one known RSS feed then you can write to that particular flavor and version. (More about the different versions can be found on Wikipedia.) Unfortunately, if you try to simply XHR to a RSS feed you'll run into the lovely cross origin browser doohicky that prevents you from making requests to another server. Of course, if the RSS is on the same domain, that isn't a problem. And of course, if you are building something in Apache Cordova, then it isn't a problem either. (Just don't forget to update the CSP!) And finally - if you control the RSS, you could add a CORS header to it so modern browsers could use it. Unfortunately, if none of those apply, you're out of luck trying to do it completely client-side. (Well, until we get to the next options!) Let's pretend that none of the roadblocks apply to you and look at a simple example. (As a quick note, none of my sample code will actually render anything. It will just get crap, parse it, and log data. I'm assuming folks know how to manipulate the DOM. I've heard there's a good library for that.)
$(document).ready(function() {
//feed to parse
var feed = "http://feeds.feedburner.com/raymondcamdensblog?format=xml";
$.ajax(feed, {
accepts:{
xml:"application/rss+xml"
},
dataType:"xml",
success:function(data) {
//Credit: http://stackoverflow.com/questions/10943544/how-to-parse-an-rss-feed-using-javascript
$(data).find("item").each(function () { // or "item" or whatever suits your feed
var el = $(this);
console.log("------------------------");
console.log("title : " + el.find("title").text());
console.log("link : " + el.find("link").text());
console.log("description: " + el.find("description").text());
});
}
});
});
So all I'm doing here is using jQuery to request my RSS feed. I then use jQuery's built in XML parsing to iterate over the <item> blocks in my RSS feed. As you can see, I'm using sample code from a StackOverflow answer that I modified a tiny bit. Specifically the answer iterated over <entry> blocks, not <item>. Remember when I said there were different flavors of RSS? That's an example of the issue right there. If you must write code to handle both cases, you would need to look for <item> first and then <entry>. But that's basically it. If your curious, I tested this in Canary with --disable-web-security as a command line flag.

YQL
Remember YQL (Yahoo Query Language)? The last time I blogged about it was way back in 2010 (Proof of Concept 911 Viewer). As a gross simplification, YQL acts like a "query language" for the web. You can literally run SQL like content against URLs and get formatted data out of it. They provide a powerful testing console and wouldn't you know it, one of the examples is a RSS parser:

Just in case that screenshot is a bit too small, here is what the YQL statement looks like:
select title from rss where url="http://rss.news.yahoo.com/rss/topstories"
I've got one word for that. Bad ass! Like, kitten in armor bad ass!

I tested with two different RSS flavors and YQL had no issue handling either. Note the REST query URL at the bottom. I copied that into a new file:
$(document).ready(function() {
var yql = "https://query.yahooapis.com/v1/public/yql?q=select%20title%2Clink%2Cdescription%20from%20rss%20where%20url%3D%22http%3A%2F%2Ffeeds.feedburner.com%2Fraymondcamdensblog%3Fformat%3Dxml%22&format=json&diagnostics=true&callback=";
$.getJSON(yql, function(res) {
console.log(res);
}, "jsonp");
});
And it worked like a charm. Note the use of JSON/P to sidestep needing CORS. And here is the result:

A big thank you to Addy Osmani from Google for reminding me that YQL was still around. Google, I forgive you for killing the Feed API now.
Feednami
Last but not least is a brand new service, Feednami, created just in time for the death of the Google Feeds API. To use it you simply add a new script to your code and then use feednami.load() to get your feed. Here is an example:
$(document).ready(function() {
var url = 'http://feeds.feedburner.com/raymondcamdensblog?format=xml';
feednami.load(url,function(result){
if(result.error) {
console.log(result.error);
} else {
var entries = result.feed.entries;
for(var i = 0; i < entries.length; i++){
var entry = entries[i];
console.dir(entry);
}
}
});
});
That's also pretty darn easy to use. Here is the result:

Summary
So - you've got options. Which one is best? Honestly I don't know. YQL requires the least amount of code from what I can see, but I kinda dig Feednami's look a bit more. If you've used any of these in production, drop me a comment below with your thoughts!
Archived Comments
Hey, I want to mention that there is also Superfeedr. We've been here for a couple years too.
The biggest difference with YQL i guess is that we charge for our API and that this is our core business... Free services from Google or Y! (remember Yahoo! Pipes?) always end up shut down at the expense of the ecosystem built around them, mainly because there's little incentive for them to keep them up in the long run.
Try Goose Parser, man! https://github.com/redco/go...
Yeah! I've tried it. It's amazing one.
Thanks folks (below) for offering up even more options! :)
One big feature from google feed api is/was to search for all rss feed on one domain. Superfeedr has it on the feature list for 2016 ...
Is this something you would actually use though? It doesn't seem like something most folks would.
I want to mention that the kitten in armor made my day— nay, my life.
If you see me post something without a kitten, check to ensure I've not been taken over by the pod people.
A forum post from a Google employee last week said Google Feed is back up and running and they are yet to decide what to do with it. Seems nuts to drop a useful and self-running service. Can't cost them much to run. YQL seems like a good alternative. I tried to find out what their cache policy is, if there is a cache at all, but to no avail. Feednami is pretty cool (a drop-in replacement for Google Feed) but anyone relying on it to feed a production site/app is dependant on the developer keeping the back-end running. Maybe he could release the server code or as a cloud package for Google/Amazon. :-)
Got a link to that post?
To be honest - that pisses me off. If you are going to shut down a service, do so. Don't by wishy-washy.
What annoys me is there isn't a termination date. A depreciation date is completely different. The date it switches off is far more useful than the date it begins to drag on and might or might not stop when someone feels like flipping the switch. Here's a link to the conversation. Read John's first post (Dec 5) and then scroll down to his second one on 8th. https://developers.google.c...
BTW, I think YQL has a caching issue? A Y! blog says to add _maxage=3600 as a URL parameter but my server still logs every single hit from Y! It's user agent string is YahooCacheSystem.
Sounds like something to report to Yahoo.
Using the first example, I keep getting a "not well-formed" error, and the console can't even tell me where the error is or what it means. Do you have any idea what it's talking about?
Did you run into the cross domain issue?
I just retested my code locally (using a copy of the XML feed also locally) and it worked fine.
No, the code's on the same server as the file. The logging works, but I'm just confused about what Firefox means by not well-formed.
I dunno, maybe it's just complaining because I use C++ layout style and JavaScript, in most examples I've seen, uses a layout akin to C#, so maybe it's just saying I'm unconventional?
Either way, it's a good example. I can easily change the output so that it adds HTML to my site. Thanks a bunch for this. 0.-.<
No worries!
Oh, something you should probably mention in the tutorial, I figured this out when trying to fix my own news feed because it kept disappearing. Sometimes, using the full URL, including the domain name and such, causes it to fail, so the success function is never even run. I changed mine from "kelvinshadewing.net/feed.xml" to just "feed.xml" and now it works perfectly for me. (Assuming you didn't already mention that, since I didn't re-read it, heheh.)
How can we get rss feeds directly from a website on the net without getting any error like
"XMLHttpRequest cannot load "aSiteOnTheWeb". Origin null is not allowed by Access-Control-Allow-Origin. " ? ty
*Sry for my bad english tho
You can't - unless the remote server is using CORS to serve the RSS. It is a browser security issue.
Ok, thanks. :)
So How shall I retrieve news dynamically from "The Guardian" for example and put it on my website ? :/
Err... follow what I said in this blog post?
I followed the first example. When i try with a local xml file, it works. But when i try with an xml file on the web, Chrome send me the error i gave above. And sadly, I don't know why...
I hate to be rude - but you really need to *read* the blog post. The first option *specifically* points out it has to be local. You do see that, right? That's why I discuss the other options.
Oh you're right ! I'm so sorry, next time i'll reread all the article before posting a comment ! My english is so bad ( i'm french ) and i think i didn't understand all that you wrote. Fortunately you answered me fast, thank you :)
No problem and glad you got it. Au revoir!
You can use a CORS proxy, such as https://crossorigin.me/
Sorry for asking on this old post, but do you know how to get more than 10 results using YQL?
Does the RSS feed your parsing have more than 10 items?
Haha good point.. Yeah I guess there are only 10 items. And seems like loading older stuff is not really supported, so thanks anyway!
Thanks for the post! Very relevant to what I'm doing right now.
You are most welcome.
YQL stopped working or inconsistent
Seems to be working ok for me - but all I did was test the URL I used in the demo above.
YQL is intermittently down - use the YQL console with diagnostics ticked (I think that prevents caching). It's been up and down like a yo-yo since last Thursday morning (EST). More down than up.
I have the same issue with YQL. You get a result, if you are lucky - or not.
yes, yql rss feed become inconsistent
I get the below pasted error while i try extracting rss from "http://timesofindia.indiati...". Can you please help me in resolving this issue?
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access
Yes, that's covered in my first suggestion. I didn't specify the error though so I apologize, but that's what your running into. You need to use one of the other suggestions.
there is a descrption tag in money control http://www.moneycontrol.com...
from description tag i want only image..how to do this
Well it's in the XML. You can extract it using XML parsing in JavaScript. What did you try?
i have used that its working fine.i have parsed var feed = "http://www.moneycontrol.com..."|; but instead of this if i am using some other link like "http://profit.ndtv.com";its throwing error like
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access..can u help me...i want multipe feed to be call.
my code is like this:
var a=[];
$(document).ready(function() {
//feed to parse
var feed = "http://profit.ndtv.com";
$.ajax(feed, {
accepts:{
xml:"application/rss+xml"
},
dataType:"xml",
success:function(data) {
$(data).find("item").each(function () {
var el = $(this);
title = el.find("title").text();
link = el.find("link").text();
string = el.find("description").text();
stringarr = string.split(">");
img = stringarr[0]+">";
//formated2 = "" + title + "
" + link +"
" + img + "
"
formated1 = " " + title + "
" + img + "
"
hello(formated1)
});
}
});
});
function hello(data)
{
a.push(data);
var r=document.getElementById('news');
r.innerHTML=a;
}
</script>
That's the CORS issue I mentioned in the first part of the blog post.
Great solution. thanks
Starting this year, 2019, the YQL stops working. I am in need of a javascript rss reader replacement.
Did you try the other two suggestions?
Feednami isn't working in hosted site but works fine in local. It says 403 forbidden -Hostname in referer header is not registered.
Is there a way to fix it?
Did you register the hostname? https://toolkit.sekando.com...