CodeKicks.com
Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Tuesday, November 14, 2006

Creating RSS Feeds in .NET

Introduction
Last week I (Scott Mitchell Scott Mitchell Scott Mitchell), authored an article titled Syndicating Your Web Site's Content with RSS Syndicating Your Web Site's Content with RSSSyndicating Your Web Site's Content with RSS , which examined using RSS to syndicate Web content. RSS is a syndication standard that specifies the syndication format. As discussed in this previous article, we saw that RSS feeds must be XML-formatted files, with an <item> tag for each content item that you want to syndicate.

In addition to examining the fundamentals of RSS, the Syndicating Your Web Site's Content with RSS also looked at creating an actual RSS feed for ASPMessageboard.comASPMessageboard.com ASPMessageboard.com. Specifically, we stepped through the process of creating an RSS feed that syndicates the messageboard's 20 most recent posts. (You can check out the RSS feed directly at http://www.aspmessageboard.com/scripts/rss.asp.)

In this article we will examine how to consume an RSS feed via an ASP.NET Web page. Specifically, we'll display the data from the ASPMessageboard.com RSS feed using a DataGrid. To improve performance, we'll look at how to use caching to cache the RSS feed results for a 20 minute period. When I sat down to create this code example, I had no idea it would be as easy as it turned out to be. Read on, and see how ASP.NET only requires four or five lines of code to display nicely formatted, remote XML data on a Web page. Truly amazing!

Getting the Remote XML Data Into a DataGrid
In order to display the data from the ASPMessageboard.com RSS feed, the first thing we need to do is retrieve the RSS feed data (the XML content) from the ASPMessageboard.com Web site. This, believe it or not, can be accomplished with one line of code: More

Post a Comment