Consume any feed regardless of format?

Topics: Argotic.Core, Request For Comments (RFC)
Jun 12, 2007 at 5:58 AM
Hi Brian,

Just about finished the dnrTV on Argotic, and I'm really intrigued by your framework.

I'm wondering if you have plans to support "format agnostic" feed consumption.

Here's my idea:

You create some interfaces, something like this:

interface IFeed
{
string Title { get; }
DateTime LastUpdated { get; }
Uri Link { get; }
/* etc */
IList<IFeedItem> Items { get; }
}

interface IFeedItem
{
string Title { get; }
DateTime Posted { get; }
Uri Link { get; }
string Body { get; }
/* etc */
}

So these two interfaces would represent the union of the features supported by all the different feed formats.

You then make RssFeed and AtomFeed implement IFeed, and you make RssFeedItem and AtomFeedEntry (I think that's its name) implement IFeedItem.

Now, you give us a "factory" class which, given a URI, sees which format that feed is and returns an IFeed object, which is actually the appropriate type (RssFeed or AtomFeed).

That means that users of your framework wouldn't have to know or care what type the feed is that they're consuming. They would just play with IFeed and IFeedItem.

Of course, this means not being able to use any format-specific features or extensions, but I think it would be a worthwhile trade-off for those of us who simply want to display a list of items.

Thanks for listening! Keep up the great work!

Matt Hamilton
Jun 12, 2007 at 4:34 PM
Matt,

In the current version of the framework both RssFeed and AtomFeed inherit from SyndicationFeed which implements the ISyndicationFeed interface, which defines a public property named Format of type SyndicationFormat enumeration. It would certainly be possible to modify the framework to provide a GenericFeed class that would enable format agnostic feed consumption. I would like to hear more about the particular use case scenario you have where you do not already know the format of the syndication service you wish to consume.

Currently you can utilize the AutoDiscovery utility class in the framework to return a collection of SyndicationEndpoint entities for a given URL. This provides a means for developers to retrieve all of the syndication services being broadcast by a web site via <link> tags, which is how web browsers like Internet Explorer 7 and FireFox 2 'know' when to provide a feed link in their navigation bars.

For now I would recommend you use the AutoDiscovery utility class to retrieve a collection of syndication end-points available for a web site, and then use the IsAtomFeed/IsRssFeed properties of each SyndicationEndpoint that is returned to determine that the end-point represents a syndication feed of a particular type you can then consume as usual.

I think your idea of a format agnostic consumption of syndication feeds has merit, and I will explore providing a means of format agnostic consumption in the future.
Jun 13, 2007 at 12:26 AM
Hey Brian, thanks for the reply.

The particular use case I'm thinking of is in my hobby project, Comicster (http://www.comicster.net). The program consumes a few RSS feeds, some of which are generated by comiclist.com, via feedburner. Recently the webmaster of comiclist.com wanted to change his feeds to ATOM rather than RSS, without changing the URL (since feedburner doesn't care). Since I'm using some very simple code to consume RSS, it broke the feeds.

So the idea is that I could add feeds to my program, and if the user decided to change them it wouldn't matter.

I totally get that I can use the SyndicationFormat type and determine the feed's format in advance, but I've recently been getting into WPF, and with its extremely powerful DataBinding, it would seem that it'd be nicer to have a single interface to bind to to get the basic details of a feed, and all of its items. As it stands, RssFeed and AtomFeed are very differently structured (which makes sense since they're structured to mirror the formats themselves).

Anyway, keep up the good work!

Matt
Jun 13, 2007 at 4:32 PM
Edited Jun 13, 2007 at 4:33 PM
Matt,

Looking at FeedBurner, I can see the use case where the feed publisher provides a syndication endpoint that's format is dynamic (can be switched between RSS and Atom). I will create a work item to add a feature to the framework whereby there is a means of consuming a syndication feed in a format agnostic manner.
Jun 13, 2007 at 11:26 PM
Lovely! Thanks Brian. I look forward to ripping out my ugly code and replacing it with your shiny DLLs in the future! :)
Jun 26, 2007 at 11:44 PM
Matt,

Just FYI, I have created the Implement means of consuming syndication feeds in a format agnostic manner work item to address this feature request. Tenative release is 2.2.0.0
Jun 27, 2007 at 1:03 AM
Excellent! Looking forward to it, Brian!