Blog

How To Read RSS Feeds With C# And Mono

Today I whished to add RSS and Atom support to one of my projects. When I took a look at the standard I realised it would be naif to spend time trying to support all the versions and imcompabilities of RSS. I then searched for projects implementing this and found one, to RSS, that fitted the profile I was looking for.

RSS.Net is an opensource (MIT) library that works both in Mono and MS.Net. It is implemented to support .Net 1.1 and supports both reading and writting of RSS feeds. While there are no binaries released it is pretty easy to build.

This was the code needed to test:

RssFeed feed = RssFeed.Read(“http://rss.slashdot.org/Slashdot/slashdot”);
RssChannel channel = feed.Channels[0];
foreach (RssItem item in channel.Items)
Response.Write (String.Format (“<a xhref=’{0}’ title=’{1}’>{1}</a><br/>”, item.Link, item.Title));

And it worked perfectly in a newly created Web Application, it displays the last Slashdot Stories. Of cource I do not whish to have the URLs hard-coded into the code and it lacks much more things. This is just enough to get started and realize how easy is to get RSS and .Net/Mono together.

I still need to improve this code, and add Atom support, so I guess I’ll come back in a few days with a more elaborated demo.

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

3 Responses to “How To Read RSS Feeds With C# And Mono”

  1. fred fenimore says:

    there is an atom. net as well out there..

  2. NEMO says:

    yeah, but Atom.NET supports only Atom 0.3. and as far as I
    know, there’s no library to support 1.0

  3. paraFLU says:

    LOL :) boo version of your code working ;) Goooood Library thanks for
    the post :)

    [code]
    import Rss

    feed = RssFeed.Read("http://rss.slashdot.org/Slashdot/slashdot")
    channel = feed.Channels[0]

    for item as RssItem in channel.Items:
    print
    "${item.Title}\n${item.Description}"
    [code]

Leave a Reply

For spam filtering purposes, please copy the number 4795 to the field below: