Thursday, November 02, 2006 5:28 PM
bart
Exploring the IE7 RSS platform in C# - Part 2
Introduction
Internet Explorer 7 introduces a unified approach to RSS. More information can be found on the RSS team blog. The good thing about it, is its availability for developers to consume the RSS feeds of the end-user, for example to build a custom RSS aggregator. Applications like the Windows Sidebar in Vista, the Windows Live Mail Desktop client, Outlook 2007 leverage the power of this API to provide multiple views on the same RSS information. In this series of blog posts I'm showing you little snippets to make a jumpstart with the RSS platform. At the end of this series, a nice (maybe geeky) application will bring together all of the pieces, so watch my RSS feed!
Getting started
For this simple demo, create a new C# Console Application in Visual Studio 2005 and add a reference to the COM component Microsoft.Feeds 1.0. This will build the required interop assembly to be used by our application to consume RSS feeds and obtain RSS information. In Program.cs import the Microsoft.Feeds.Interop namespace:
using Microsoft.Feeds.Interop;
Retrieving feed information
RSS feeds (to which the user has subscribed) are represented by the IFeed interface. In the previous post, we've encountered this type already. Today, we'll take a closer look at this type used to retrieve information about an RSS feed and to obtain the content of a feed item. Here's the code:
void Main(string[] args)
{
FeedsManager mgr = new FeedsManagerClass();
IFeed feed = (IFeed) mgr.GetFeedByUrl("http://community.bartdesmet.net/blogs/bart/rss.aspx");
foreach (PropertyInfo info in typeof(IFeed).GetProperties())
Console.WriteLine("{0} = {1}", info.Name, info.GetValue(feed, null));
Console.WriteLine();
Console.WriteLine("Items:");
int i = 0;
foreach (IFeedItem item in (IFeedsEnum)feed.Items)
{
Console.WriteLine("Feed item {0:d2}", ++i);
Console.WriteLine("============");
foreach (PropertyInfo info in typeof(IFeedItem).GetProperties())
Console.WriteLine("{0} = {1}", info.Name, info.GetValue(item, null));
Console.WriteLine();
//Use item.Xml(...) to retrieve the item's data.
}
}
This assumes you've subscribed to my feed on http://communities.bartdesmet.net/blogs/bart/rss.aspx via IE7. Make sure to check out MSDN information on IFeed and IFeedItem. Using this object model in a Windows Forms application shouldn't be too difficult, so you're right on the way to building your first RSS viewer with the Windows RSS Platform.
Have fun!

Del.icio.us |
Digg It |
Technorati |
Blinklist |
Furl |
reddit |
DotNetKicks
Filed under: Windows Vista, C# 2.0