Aggregating Feeds
I played around with the SyndicationFeed the other day and found that it was really useful in combination with the link collection property in EPiServer CMS. By using the trusty old friend LINQ you can aggregate the feeds, sort them and databind the whole shebang to a Repeater control or another weapon of choice. The great thing with this is that you don’t have to worry about the feed format since SyndicationFeed can parse ATOM and RSS in different versions.
PropertyLinkCollection links =
ContentFunctionData.Property["Feeds"] as PropertyLinkCollection;
if (links != null && links.Count() > 0)
{
var items =
from link in links
let feed = SyndicationFeed.Load(XmlReader.Create(link.Href))
from item in feed.Items
where item.PublishDate > DateTime.Now.AddDays(-30)
orderby item.PublishDate descending
select item;
repFeed.DataSource = items.Take(5);
repFeed.DataBind();
}
12 June 2009