How to parse RSS feeds in .NET

Are you looking for ways to parse an RSS feed using C# or VB.NET? See my the code samples here that provide and easy way to parse and iterate through items in the RSS file.

I was developing a simple application that download an RSS feed, iterate through the URLs in the RSS feed and do some processing. I knew I wouldn't need to download the file from the URL and then read the text in it. The .NET has made it very easy to work with XML and RSS files by providing several classes that can download and populate XML files with a single line of C# or VB.NET code.

You can use the XmlDocument class to download an RSS feed by providing the URL and then load it as an XML file.

See the sample code below that load an RSS file from the URL:

XmlDocument rssXmlDoc = new XmlDocument();

The above code will download the RSS file from the web URL. The only thing you need to do from now is to iterate through the items in the XML Doc and do whatever you need to do with it.

Here is the full code example that loop through the RSS items and return it as a string:

private string ParseRssFile()
XmlDocument rssXmlDoc = new XmlDocument();

// Load the RSS file from the RSS URL

// Parse the Items in the RSS file
XmlNodeList rssNodes = rssXmlDoc.SelectNodes("rss/channel/item");

StringBuilder rssContent = new StringBuilder();

// Iterate through the items in the RSS file
foreach (XmlNode rssNode in rssNodes)
XmlNode rssSubNode = rssNode.SelectSingleNode("title");
string title = rssSubNode != null ? rssSubNode.InnerText : "";

rssSubNode = rssNode.SelectSingleNode("link");
string link = rssSubNode != null ? rssSubNode.InnerText : "";

rssSubNode = rssNode.SelectSingleNode("description");
string description = rssSubNode != null ? rssSubNode.InnerText : "";

rssContent.Append("<a href='" + link + "'>" + title + "</a><br>" + description);

// Return the string that contain the RSS items
return rssContent.ToString();

The above code sample is in C#, but if you are looking for VB.NET examples, it is quite easy to convert the code in to VB.NET. You may manually change the syntax or use one of our C# to VB.NET convert tools

If you are using .NET Framework 3.5 or above, you may use the SyndicationFeed class as well.

RSS Reader - Third party utility to parse RSS files

There are several other ways to parse RSS files like the RSS Reader project in the Codeplex. Such tools were very useful in the past before the convenient classes and methods were provided by the .NET Framework itself. Now a days, the .NET class libraries are very rich and you rarely have to use any third party tools for simple tasks like parsing RSS feeds.


Guest Author: mohsen.r04 Mar 2013

This code is great but this code give string that have all rss link in the site
now how to show them in c# web app use textbox or list box or etc get me some sample

Guest Author: shashi shanker singh05 Jul 2013

Really nice coding thank you for this.You are genius....

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: