Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Control Your Feeds with Windows Vista's New RSS Platform : Page 2

By adding OS-level support for RSS in Vista and making that support available to .NET developers, Microsoft has provided an easy way to build completely new classes of applications with little additional effort.


advertisement
The RSS Object Model
The FeedsManager object is the top-level entity you deal with to access underlying feeds. If you've used any type of RSS reader, you're probably familiar with the concept of arranging your feeds in groups by some common interest. Many readers, including the one in IE 7, let you create folders to group feeds. The Common Feed List supports the concept of hierarchical folders; each folder can contain feeds or other lower-level folders.

Figure 1. Source, Microsoft: MSDN Object Model for the RSS Platform: The FeedsManager is the top-level object. It has a collection of FeedFolders, each of which can contain feeds or other folders.
Within the folders a Feed object contains a collection of items including feed and channel properties. This approach provides feed information through Feed object properties, but if necessary you can access the raw feed XML and deal with it programmatically instead. The FeedItem object has individual item properties such as a read/unread property along with the actual enclosure. The FeedEnclosure object exposes enclosure properties including the local path where enclosures reside in the file system.

The MSDN documentation depicts the object model as shown in Figure 1.

Getting Started with RSS
Here's the code for a simple VB.NET program that uses RSS Platform API methods to display all the subscribed feeds from the Common Feeds List in a list box when users click a button:

Imports Microsoft.Feeds.Interop Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim root As IFeedFolder Dim manager As New FeedsManager root = manager.RootFolder For Each feed As IFeed In root.Feeds ListBox1.Items.Add(feed.Name) Next End Sub End Class

Here's the equivalent version in C#:

Figure 2. Feed Object Properties and Methods: Here's an Intellisense popup showing the methods and properties for the Feed object.

using Microsoft.Feeds.Interop; public class Form1 { private void Button1_Click( object sender, System.EventArgs e) { IFeedFolder root; FeedsManager manager = new FeedsManager(); root = manager.RootFolder; foreach (IFeed feed in root.Feeds) { ListBox1.Items.Add(feed.Name); } } }

Author's Note: Special thanks to Microsoft's Mike Taulty for his help with the code in this article.

The preceding code examples use two RSS API objects: IFeedFolder and FeedManager. These two together provide access to the Common Feed List. The nice part about IFeedFolder is that you can iterate over it to walk through the data. Note the syntax of the For Each loop.

You can use the Intellisense feature of Microsoft Visual Studio to look at the different methods and properties of the feed object. Figure 2 shows a partial list of the methods and properties as shown in the Intellisense popup for the Feed object.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap