ASP.NET 2.0
Data Access
Data Controls
Integration
.NET Security
Communication
XML
IT Project Management
Articles > ASP.NET 2.0 > Consuming an RSS feed in ASP.NET 2.0

Consuming an RSS feed in ASP.NET 2.0

Written by Osamah Alabdullah

RSS stands for Rich Site Summary or Really Simple Syndication. Since its introduction, it has gained a lot of popularity and is now becoming the standard for quick and simple information exchange on the Internet.

ASP.NET 2.0 offers new controls which makes consuming an RSS feed a breeze. In this article, I will show you how easily you can consume an RSS feed without writing any code (well may be just a little)

Approach:

The approach is very simple. Place an XmlDataSource control and provide the URL to the feed and the Xpath to the feed's contents.

Subsequently, place a DataList control and assign its datasource property to the XmlDataSource you configured earlier.

Lastly, edit to the ItemTemplate in your DataList to show the feed.

Here are the steps again with an exmaple:

  1. Drag and drop a XmlDataSource to your page.
  2. Right click the XmlDataSource and select "Configure Data Source".
  3. Enter the entire web address to the RSS feed in the "DataFile" field.
  4. Enter the following in the XPath field: /rss/channel/item
  5. Click "OK".
  6. switch to "HTML Source View" and include the following code  between your datalist tags:
<ItemTemplate>
        
<a href="<%#XPath("link")%>"><%#XPath("title")%></a><br />
         <%#XPath("description")%><hr />
</ItemTemplate>

That's all. Happy programming!

This web site uses Kentico CMS, the content management system for ASP.NET developers.