Syndicate Your Site

Dynamically Create RSS Syndication Feeds

Scott Mitchell

October 30, 2009

17 Min Read
ITPro Today logo in a gray background | ITPro Today

asp:feature

LANGUAGES: C#

ASP.NET VERSIONS: 1.0 | 1.1 | 2.0

 

Syndicate Your Site

Dynamically Create RSS Syndication Feeds

 

By Scott Mitchell

 

If you visit many weblogs, such as those at http://blogs.msdn.comor http://weblogs.asp.net,you may have noticed that many blogs contain a little orange button with thetext XML or RSS (see Figure 1). Clicking on that button takes you to a pagethat dumps out a bunch of XML content. This XML content, called an RSSsyndication feed, contains information about the blog's latest posts, such asthe title of a post, when it was made, a link to the complete post, and asynopsis of the post. RSS is a standard that specifies an XML format for syndicatingmetadata about Web site content in a machine-readable format.

 


Figure 1: Sites that provide an RSS feed typically use a little orangebutton that links to the site's RSS feed.

 

Syndicating content through RSS isn't limited to blogs; abevy of Web sites syndicate information about their content using RSS,including CNet's News.com, Yahoo! News, eWeek.com, and Microsoft's MSDN site.You may be wondering why any Web site would want to syndicate metadata aboutits content. There are two main reasons:

 

One. Other Websites can read the syndicated information, and display this on their own Website. This gives the syndicated content more exposure since it can be easilydelivered to multiple Web sites.

 

For example, at the official ASP.NET Web site (http://www.asp.net), there's an RSS feed listingthe latest ASP.NET-related articles on the Web. On the Web site I run,4GuysFromRolla.com, I list these recent articles on the homepage (http://aspnet.4GuysFromRolla.com),so a visitor to my site can see the titles and descriptions of the latestASP.NET articles gathered by http://www.asp.net.Clicking on one of these titles will take the user to the particular article.

 

Two. Manypeople are starting to use RSS aggregators as a means for keeping up-to-datewith online information. An RSS aggregator is a desktop or Web application thatperiodically checks the RSS feeds from a specified list of sites. If there areany new content items, the RSS aggregator alerts the user so that they can viewinformation about the new content through their aggregator program, withouthaving to fire up a browser and visit the site. Web sites that want to attractthose who are using RSS aggregators need to provide information about theirlatest content using RSS.

 

In DisplayingSyndicated Content, which examined how to consume an RSS feed and displayit in an ASP.NET Web page. In this article, we'll look at how to syndicatecontent using RSS. The lessons learned and code presented in this article willbe especially beneficial to those who maintain a Web site that provides regularlyupdated content and who are interested in extending their content's reachthrough syndication.

 

The History of RSS

By 1999, Netscape was creating its my.netscape.com Website, which, like My Yahoo! and other personalized portal sites, allowed usersto customize the information displayed on the personalized portal's home page.Netscape needed a standardized way to consume and display different content ona user's personalized homepage. To surmount this problem, they introduced astandardized way by which a Web site could syndicate information about itscontent. This standard was called RDF Site Summary (RSS) 0.9, as it requiredconformance to a previous W3C standard called RDF. (RDF is a standard forproviding information in a machine-readable, XML format. See http://www.w3.org/RDF/ for more information.)Eventually RSS 0.9 became RSS 1.0.

 

As the RSS 1.0 specification was being formed, Netscapeintroduced RSS 0.91, which dropped the adherence to the RDF specification. DaveWiner then independently extended RSS 0.91 to RSS 0.92, adding functionality tothe RSS spec. The latest work on RSS done by Dave Winer is RSS 2.0. With thislatest version, Dave has changed the meaning of the RSS acronym from RDF SiteSummary to Really Simple Syndication.

 

The important thing to understand is that there is a bitof a difference between the various RSS versions, most noticeably between RSS1.0 (which maintains adherence to the RDF standard), and RSS 0.91, RSS 0.92,and RSS 2.0 (which does not). When deciding to syndicate your Web site'scontent, you'll need to choose which standard to use to syndicate your site'scontent. There's really no wrong choice; virtually all RSS aggregatorapplications can consume both valid feeds from any RSS version. However, Iwould encourage you to use the latest version, RSS 2.0, as it is the standardversion we'll be syndicating for in this article. Therefore, from this pointforward, when I use the term RSS I am referring to RSS 2.0.

 

Know the RSS 2.0 Specification

RSS is designed to syndicate information about Web sitecontent. For example, the Web site I maintain, 4GuysFromRolla.com, offers anRSS feed (http://aspnet.4GuysFromRolla.com/rss/rss.aspx)that provides the following information about the 10 most recent articles:

  • The title of the article.

  • The URL of the article.

  • The date and time the article was published.

  • A short synopsis of the article.

 

The RSS specification provides pre-defined XML elements toexpress this and other information about a Web site's content items.Additionally, RSS provides XML elements to furnish information about thesyndication channel. In RSS, a channel provides specific syndicated content.Each RSS feed contains a single channel. A Web site can contain an arbitrarynumber of RSS feeds, and can therefore contain an arbitrary number of channels.A Web site might opt to use multiple RSS feeds, having each feed focus on aspecific type of content. Yahoo! News, for example, provides 16 separate RSSfeeds at http://news.yahoo.com/rss- one for top stories, one for U.S. news, one for world news, one for businessnews, and so on. RSS channels are akin to television channels in that each TVchannel provides a specific type of content, e.g. MTV provides music videoswhile CNN provides news.

 

The basic form of an RSS 2.0 document contains an element as the document root. The element contains asingle child, . In the element are elementsproviding information about the RSS channel itself, as well as an element for information about each syndicated content item (see Figure 2). Theofficial RSS 2.0 specification is available online at http://blogs.law.harvard.edu/tech/rss.

 

  

    

    http://www.4GuysFromRolla.com/

    Thelatest headlines from

                         4GuysFromRolla.com

    Copyright 2004 Jupitermedia

              CorporationAll Rights Reserved.

    180

    en-US

    [email protected]

    

      

      http://4guysfromrolla.com/020404-1.aspx

      

        This article looksat using HTTP handlers to

        prevent HTTPaccess to certain types of files.

      

      [email protected]

      Wed,08 Feb 2004 03:12:00 GMT

    

    

      

      http://4guysfromrolla.com/012804-1.aspx

      

        This articleexamines skmMenu, an open-source

        custom ASP.NETmenu control.

      

      [email protected]

      Wed,28 Jan 2004 06:51:00 GMT

    

    

      

      http://4guysfromrolla.com/010704-1.aspx

      

        This article, byJisun Lee, examines how to create

        and consume .NETWeb services.

      

      [email protected]

      Wed,07 Jan 2004 12:09:00 GMT

    

  

Figure 2: An RSS 2.0 syndication feed contains an element for each of the site's recent content items. The elementspreceding the elements provide information about the Web site.

 

As Figure 2 illustrates, the RSS feed contains a single element. The is described with elements such as

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like