Accessing Rss Feeds

Published on by Inno Design

RSS is a format for an XML document that describes a list of items, such as blog entries or news headlines. The document may just be a stream of XML created on the fly rather than a static file. In this post, we’ll tell you to put an RSS document (using Version 2.0) on a page by using the XmlDataSource and DataList controls.

Well what you need for this are as given below

  • URL to a valid rss file it could be .xml,.rss,.aspx.,.php etc
  • kind of schema of that rss file we call Xpath, to reach upto the content you are interested in.

A typical Rss file is like this.

A typical schema is like this


XPath rss/channel/Item tell that this is Item from where you want to start fetching from.

Now i guess enough theoretical content has been described.

let’s start working.

Create a web site,

in default page or wherever you want to display the feeds put xmldatasource.

in navigationurl put the url of the rsss file. one example is ( if you are choosing this Rss then put XPath=”rss/channel/item”.

take a data list and set its DataSourceID to the id of XmlDataSource you have taken.

in datalist set enableViewState to false.

Item template would be like this.

Title:<%# XPath(“title”) %><br /><br />
Description:<%# XPath(“description”)%>
<hr />

XPath(“Tiitle”) will print content of the Title tag and Xpath(“description”) will print content inside Description tag.

complete markup code is like this

<%@ Page Language=”C#” AutoEventWireup=”true”  CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

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

<html xmlns=””>
<head runat=”server”>
<form id=”form1″ runat=”server”>
<asp:XmlDataSource ID=”XmlDataSource1″ runat=”server”
<asp:DataList ID=”DataList1″ runat=”server” DataSourceID=”XmlDataSource1″ EnableViewState=”False”>
Title:<%# XPath(“title”) %><br /><br />
Description:<%# XPath(“description”)%>
<hr />

Run the project and see the feeds from your favorite site. Enjoy.

Published on ASP.NET

Comment on this post