RssFeed Version 1.9 Available
A new version of RssFeed - everybody's favorite ASP.NET server control for displaying RSS feeds - has been released. The new version 1.9 adds two notable improvements:
- The RSS feed “slurping“ code/logic has been decoupled from the server control-related code, and
- Support for the <enclosure> element has been added. In RSS version 2.0 this element is used to associate some external document with the item, and is commonly used in podcast syndication.
Item #1 is the one I'm most excited about. Previous to this version, the code for sucking down the RSS content was embedded deep within the server control. But why? This prevented developers from using my control if they wanted complete control over how the data was displayed... or maybe if they didn't want the data displayed at all. For example, imagine that you wanted to periodically grab a feed, see if any of its items' descriptions contain a particular substring, and then save those results to a database (or email someone, or whatever). Previously this was not possible with RssFeed - now it's a snap.
Want to grab an RSS feed from a remote server? Just do:
RssEngine engine = new RssEngine();
RssDocument doc = engine.GetDataSource(url);
Want to enumerate the items in the returned RSS feed looking for descriptions that contain the term “ASP.NET“? Simple:
foreach(RssItem item in doc.Items)
if (item.Description.IndexOf(”ASP.NET”) >= 0) ...
In fact, you could use this logic to strip out those entries that don't have the term ASP.NET in them and then bind that modified RssDocument instance to the RssFeed control by assigning it to the control's DataSource property and calling the DataBind() method. Check out a demo of the RssEngine class.
The enclosure support now makes it easy to display a podcast using RssFeed, including a “Download” column that links to the items enclosure. You can see a list of the KPBS News podcast for San Diego at this live demo. Note how those items that have an associated media file specified via an <enclosure> tag have the Download link in the right column. Click it and start listening to the podcast!
To top it all off, there's even a 4Guys article detailing this new version: Displaying RSS Feeds - A Look at Version 1.9. You can download RssFeed and check out the online (or offline) documentation at the official RssFeed homepage; there are also a slew of live demos available.