Manage your Feeds with RSSToolkit

15 09 2010

A good resource when you need to read or generate feeds like RSS, Atom, OPML or RDF : RSS Toolkit (http://aspnetrsstoolkit.codeplex.com/).

RssToolkit is a complete and simple framework to manipulate your RSS feeds in your .NET projects, from reading to generating them. Moreover, knowledge about Atom or Rss standard is not necessary : you can easily switch from RSS to Atom when generation is required.

With this main class named RssDocument, reading feed can be easily done like that:

RssDocument rss = RssDocument.Load(new Uri("http://myfeed.com/feed"));

and manipulating an object that correspond to a Rss content(channels & items) is available.
Note that a webcontrol exists to manage items collection (RssDataSource) and allows a direct binding with them.

Another sample is a simple page that will represent our feed:

protected void Page_Load(object sender, EventArgs e)
{ 

RssDocument Rss = new RssDocument();
Rss.Channel = new RssChannel();
Rss.Version = "2.0";
Rss.Channel.Title = "My channel";
Rss.Channel.PubDate = DateTime.Now.ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'",System.Globalization.CultureInfo.InvariantCulture);
Rss.Channel.Link = "http://www.mysite.com/";
Rss.Channel.WebMaster = "webmaster@mysite.com";
Rss.Channel.Description = "Site's News";
Rss.Channel.Items = new List<RssItem>();
Rss.Channel.Items.Add(new RssItem(){
   Title="item1",
   Description="desc1",
   PubDate=DateTime.Now.ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", System.Globalization.CultureInfo.InvariantCulture)
})
Rss.Channel.Items.Add(new RssItem(){
   Title="item2",
   Description="desc2",
   PubDate=DateTime.Now.ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", System.Globalization.CultureInfo.InvariantCulture)
})
Rss.Channel.Items.Add(new RssItem(){
   Title="item3",
   Description="desc3",
   PubDate=DateTime.Now.ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", System.Globalization.CultureInfo.InvariantCulture)
})
Response.Clear(); 

XmlDocument doc = new XmlDocument();
doc.LoadXml(Rss.ToXml(DocumentType.Rss));
doc.Save(Response.OutputStream);
Response.End();
}

A really useful framework to start RSS Management. The others things that it cannot do is up to you with the open source code !

Advertisement

Actions

Information

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 )

Connecting to %s




Follow

Get every new post delivered to your Inbox.