Building a RSS reader in ASP.Net


RSS Feeds are just XMLs – so building a RSS reader is not so difficult, first you know how to do it 😉

Let’s start with looking at C# function that reads the RSS Feeds.

First step is to collect the feeds. This is done by using WebRequest:

System.Net.WebRequest myRequest = System.Net.WebRequest.Create(rssURL);
System.Net.WebResponse myResponse = myRequest.GetResponse();

System.IO.Stream rssStream = myResponse.GetResponseStream();
System.Xml.XmlDocument rssDoc = new System.Xml.XmlDocument();

Now that we have collected the feeds, we are able to process the XML (rssDoc). In my example I would like to run though the items and then write the title.

This would look something like this:

System.Xml.XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item");

string title = "";
string link = "";
for (int i = 0; i < rssItems.Count; i++)
    title    = rssItems.Item(i).SelectSingleNode("title").InnerText;
    link     = rssItems.Item(i).SelectSingleNode("link").InnerText;            

    Response.Write("<a href='" + link + "' target='new'>" + title + "</a>");            
    Response.Write(" ");

That’s all, now you have a function that can collect the Feeds.

Please Notice – not all Feeds have the same XML format. They can/will differ from Feed provider to Feed provider.

Now lets take a closer look on the ASP.Net page.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20runat%3D%22server%22%3E%0A%20%20%20%20public%20void%20GetFeed(string%20rssURL)%0A%20%20%20%20%7B%0A%09%2F%2FPut%20here%20the%20code%20descriped%20ealier%20in%20this%20section%0A%20%20%20%20%7D%0A%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
<html xmlns="">
<head runat="server">
    <title>mibuso Feeds</title>    
<body style ="font-family: Tahoma,Arial,Verdana,Helvetica;">

    <form id="form1" runat="server">

                rssUrl = "";
                Response.Write("mibuso Feeds");



Here we assume, that the above C# function is called GetFeed. This function must be added in a script section and can afterwards be called from the body section.

Next you place the page on the internet server. When calling it – you should get a result like this:

That’s all, now you have a ASP.Net page, that collects the feeds and show the title.

Be the first to comment

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.