Introduction

This article will explain how to consume an RSS Feed from another website using ASP.NET 2.0. I have tried to keep this article very simple so that even beginners can easily understand this. This article will explain to you how to use RSS Feeds in eight easy steps using ASP.NET 2.0!

Background

Before you start reading/implementing the steps using this article, hope you are aware of RSS Feeds. RSS means Really Simple Syndication. Nowadays, every dynamic web site, has this feature named RSS. Using RSS Feeds, you can be in sync with the changes/additions made to your favourite shopping website or your favourite techie blog website.

Using the code

OK. Let's start. Please follow the following seven easy steps and your RSS Feed webpage will be ready to consume RSS from a given website:

Now, go to File -> New Website to create a new website. Select Location=File System, Language=Visual Basic, and give the default web site path (by default, it will create a new website at C:\Documents and Settings\default\My Documents\Visual Studio 2005\WebSites).

Transformation File = we are not currently using any XML transformation file, so leave it blank.

XPath Expression = again, this is very much important. An XPath variable will be used later on in our code to get the specific RSS Feed link. Give it as rss/channel/item now.

The next step is to drag the DataList control from Toolbox -> Data -> DataList to the WebForm.

Then, click on the Choose Data Source dropdown for the DataList and select XMLDataSource1.

And then the final step. Switch to the HTML Source View of the WebForm and paste the following code:

<ASP:DataList...><ItemTemplate></ItemTemplate></ASP:DataList>

And then, press F5 in your project to Run the project. Please refer the example source file for any further details.

Info

Q-1. How should I obtain the RSS feed path?

Ans. You will require a path to the RSS Feed from any given website to actually consume the RSS Feed of that website. In my example, I have used http://spaces.msn.com/members/mauliksoni/feed.rss, but you can use any RSS path. To get the RSS feed path from any website, try to locate the word RSS or look for its image in the website. Then click on RSS or XML, your browser will be redirected to the XML formatted page. Now copy the link form IE.

History

N/A

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

Comments and Discussions

Hi
I have created an RSS Feed in my application. I have set values for all essential values for RSS. The description attribute is set as a string that is obtained by calling a method. now What that method is doing is that it creates HTML like :
RSSCourseDisplayDetails.Append("<table><tr><td><img src='" + Global.SiteRootPath + "/Local/Images/VRM/btnLaunch.png'></td><td><a href=" + sqlDr["Course_External_URL"].ToString() + " target="+"_blank "+ " >Launch/Register</a></td></tr></table>");...........and so on…..

As you can see I have used sqlDr a DataReader to read rows returned by a stored proc in SQL Server.
So the String Builder is appended more HTML like that. and thus the whole description of the RSS item is created in tabulated format.
The issue that I am facing is that target="_blank" does not work. The link redirects to the new page in the same browser window.
I want it to open in a new browser window....Please help..