Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Free Trial Issue of Visual Studio Magazine

email article
printer friendly
get the code
more resources

Build an RSS Generator Component
Easily create an RSS feed that has many potential uses in sharing information both within and outside your organization. Learn how to build an RSS generator component you can reuse in your own applications.
by Stan Schultes

Posted January 30, 2004

Technology Toolbox: VB.NET, XML

You've undoubtedly tried numerous ways to distribute corporate information, including paper reports, Web reports, custom data reporting, and third-party data-analysis apps—all with varying degrees of success. The problem is that report users need to look in their mail slot, visit a Web page, or go elsewhere for your output. Instead, try Really Simple Syndication (RSS) feeds, a data-publishing technique based on the XML standard that lets you publish information both internally and externally. You create an RSS "feed" that interested parties can subscribe to using a newsreader (or aggregator) within custom apps or centralized in a module on your corporate portal.

ADVERTISEMENT

News content generators were the first big providers of RSS feeds, and the recent surge in popularity of Weblogs (also known as blogs) has fueled interest in the RSS publishing format. Before RSS, you had to visit each of your information sources regularly to see if something had changed. You checked e-mail, visited your favorite Web sites, and looked in your mail slot for a new hardcopy report. With RSS, you point a newsreader app to all of your information sources and it collects, updates, and notifies you of what's changed and displays a summary of each with links to detailed content—all within a single interface. This is a great time-saver for your data-hungry users.

RSS originated in 1999 and reached its current version in the fall of 2002. The RSS standard is essentially frozen at version 2, but you can add custom extensions to the spec by publishing your schema through a namespace (see Additional Resources). RSS enables you to publish content easily in a standardized XML format that a reader app consumes. RSS is a content description format, so coupled with a stylesheet or other custom formatter, you can make the RSS output look any way you like on the receiving end.

The RSS feed consists of an XML file with three parts: a header, the channel definition, and a list of items (see Listing 1). The header defines the XML and RSS versions supported in your feed. The channel section is metadata describing the RSS feed itself. Items are the individual pieces of information you're actually publishing, and you can have an unlimited number of items within a channel. Many RSS elements accept HTML markup as data, so you can do things such as provide hyperlinks and embed images in your content.

This column's sample code consists of a VB.NET class project named RssGen and a test app to drive the RSS generator assembly. RssGen contains a pair of classes: Rss and RssItem. Rss is responsible for the header and channel elements, and it contains a collection of RssItem objects. You normally call RssGen from a data access routine to regenerate your RSS output file with new data at some appropriate interval. In a typical usage scenario, you create a new Rss object, add available items using the overloaded AddItem methods, then call SaveFile to write the RSS file to disk. Download the sample object and follow along.

Create the RSS Generator Component
Fire up Visual Studio .NET and create a Class Library project named RssGen. Delete the default Class1.vb file from the project and add a new class named Rss.vb. Add Imports statements at the top of the file for namespaces you'll need in the code:

Imports System.IO   
Imports System.Text 



Back to top














Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home