Monday, July 11, 2005

Really Simple Syndication (RSS)

RSS is a Web content syndication format.
Its acronym stands for Really Simple Syndication.
RSS is a dialect of XML. All RSS files must conform to the XML 1.0 specification, as published on the World Wide Web Consortium (W3C) website.

For more info...
Click here RSS

Sample code to read RSS feed in asp.net..

private DataTable GetRSSFeed(string strURL )
{
//Retrieve the XML data
XmlTextReader reader = new XmlTextReader(strURL);
DataSet ds = new DataSet();
ds.ReadXml(reader) ;
return ds.Tables[2];
}

// for displaying the RSS feed add the following code to the page load event.
private void Page_Load(object sender, System.EventArgs e)
{
string strURL = Server.MapPath
("rss.xml"); //"http://rajeshpillai.blogspot.com/atom.xml";
dgRSS.DataSource = GetRSSFeed(strURL);
dgRSS.DataBind();
}


When the dataset is generated from ReadXML, three tables are created in the dataset, one for each rss, channel and item tag.
Since we are only interested in the item we are returning ds.Tables[2].
We can easily display this information in a datagrid or datalist.

Happy Syndicating...

No comments: