Okay, so you read the title of this post. Perhaps you're expecting huge amounts of code, but guess what. As it turns out, this is so ridiculously easy. This will be a very short post.
Step one is to have a method that loads an RSS feed. WCF offers a new class called SyndicationFeed.
private SyndicationFeed Load( string url )
{
XmlReader reader = XmlReader.Create( url );
SyndicationFeed feed = SyndicationFeed.Load( reader );
return feed;
}
The above method will take a url and use to load a feed. Now suppose I have a list of urls and I want to take all the items in all the feeds, sort them and use them to generate a new, aggregated feed. Sounds like a fair amount of work, right.
Here is the code:
private SyndicationFeed Aggregate( List<string> urls )
{
var items = from url in urls
from item in Load( url ).Items
orderby item.PublishDate descending
select item;
SyndicationFeed feed = new SyndicationFeed( items );
return feed;
}
Cool!