Life & Technology

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

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.

Advertisements

One response to “Easy RSS Syndication in .NET

  1. .Net September 1, 2011 at 9:53 am

    Great post about rss syndication in .Net
    Thanks for posting!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: