It's not that reading or writing feeds were exceedingly difficult before. FCL comes with a number of XML classes that facilitate working with XML data which all syndication feeds emanate from. No doubt there are plenty of sample code out there that made the task as easy as copy, paste and tweak. But now FCL comes with its own native classes to handle feeds, with advanced settings, intellisense, and potential of extension.
To demonstrate ease of use, here's a sample code that pulls in a sample feed from Google, and scrapes and saves the content of each link to a file:
var wc = new WebClient();
using (var rss = XmlReader.Create(
"http://finance.google.com/finance?morenews=10&q=NASDAQ:INTC&output=rss")) {
var feed = SyndicationFeed.Load(rss);
foreach (var x in feed.Items) {
var uri = x.Links.Last().Uri;
wc.DownloadFile(uri, @"c:\rss\" + Regex.Replace(uri.LocalPath, @"^.*/", ""));
}
}
That was easy, eh? Just remember to add System.ServiceModel.Web.dll as a reference to your project. Happy syndicating.
rss,atom,microsoft,net,asp.net,xml
