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!
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:
- Start -> Programs -> Microsoft Visual Web Developer 2005 Express Edition.
- 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).
- Then, drag the XMLData source component from Toolbox -> Data -> XMLDataSource to the blank WebForm.
- Click on XMLDataSource Tasks - > Configure Data Source link to configure the data source. Now, this is the actual thing in the whole project.
- Then, you will see the ConfigureDataSource window which has the following paths to be specified to consume the XML data:
- Data File = Data file will be your RSS Feed path. In my case, it is http://spaces.msn.com/members/mauliksoni/feed.rss.
- 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
- 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
- And then the final step. Switch to the HTML Source View of the WebForm and paste the following code:
And then, press F5 in your project to Run the project. Please refer the example source file for any further details.
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.