Life & Technology

Handful lessons in different areas of technology and life in general.

Tag Archives: dotnet

Easy RSS Syndication in .NET

My office colleague just asked me about the easy way to read and retrieve an RSS feed for a specific or multiple sites. And I say that Microsoft did indeed has a class called Syndication that resides under System.ServiceModel namespace that handles not only RSS but also Atom format too!

Below is a console application that I created to show how easy it is to read RSS via .NET:

Declare the import:

   1: using System.ServiceModel.Syndication;

Make sure you add the ServiceModel and ServiceModel.Web on your Reference.

live_writer_serviceModel

Basically, the main logic for reading RSS is to call the Url via the WebClient class and create an XmlReader object to hold/read the XML results being fetched on the WebClient request. And then, finally, just pass the XmlReader object to the Syndication object and it will parse all results into a feed collection.

live_writer_snippet01

and the Main() call would just be:

live_writer_snippet02

And when I run the project, the output will look similar on the screenshot below:

live_writer_rssConsole

Simple as that!

The RSSConsole Project File for this snippet is available for download here.