Linq to RSS feed?

What I'm trying to do is take the URL to read RSS and, using LINQ, be able to write a query that allows me to sort the feed subject line or sort the feed author line or even execute 'WHERE', which will allow me to filter by key words, for example.

I know that I can read the RSS feed, analyze each element, put them in some collection of class and LINQ objects, but I was wondering if Microsoft provided an easier way to do this in the .NET platform.

+5
source share
2 answers

You should look at the SyndicationFeed class .

var reader = XmlReader.Create("http://url.to/rss");
var feed = SyndicationFeed.Load(reader);

//Find items by Jesper
feed.Items.Where(i=>i.Authors.Any(p=>p.Name == "Jesper"));

//Order by publish date
var ordered = feed.Items.OrderBy(i=>i.PublishDate);
+9

All Articles