There are several ways to load and manipulate a feed.
Intellisense.png
  • Load – takes 3 overloads taking either a System.Uri, a String containg the feed's XML, or an XmlReader. You can provide RSS/Atom/RDF or OPML formatted feeds for any of these 3 overloads and it will automatically identify the base feed type and construct the class appropriately.
  • SelectItems – returns an IEnumerable which can be gives the ability to iterate over the collection. It is also used internally to provide data binding capability to RssDataSource.
  • ToXml – returns a String with the Xml of the feed in any supported format for publishing the feed . The input parameter {(enum DocumentType}} specifies the format of Xml returned as RSS/Atom/RDF or OPML.
  • ToDataSet – returns the feed contents as a DataSet. This is useful to directly assign to a data-bound control.
An example of using RssDocument directly to bind to a GridView:
void Page_Load(object sender, EventArgs e)
{
    RssToolkit.Rss.RssDocument rss = RssToolkit.Rss.RssDocument.Load(new System.Uri("http://rss.msnbc.msn.com/id/3032091/device/rss/rss.xml"));
    Image1.ImageUrl = rss.Channel.Image.Url;
    GridView1.DataSource = rss.SelectItems();
    GridView1.DataBind();
}

Last edited Jun 16, 2007 at 12:20 AM by IDisposable, version 3

Comments

andrelasantos Feb 6, 2013 at 6:25 PM 
I have troubles with ATOM format.
The first link URL is given for all following RSS itens, even with correct link set....
How do i solve it?

adron Dec 28, 2008 at 8:23 AM 
How does one force the RssDocument.Load to download more than X amount of items. On most feeds it only will download 10 or 15 feed items. Is there a way to make it trigger a download of more items?

maloca66 May 18, 2008 at 3:52 AM 
Try this on the first line of codefile:

Imports RssToolkit

And Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) ----> "Handles Me.Load"

Coleen Oct 26, 2007 at 1:47 AM 
I'm using VB.net not C#. I've converted the code above, but get errors:

Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim rss As RssToolkit.Rss.RssDocument = RssToolkit.Rss.RssDocument.Load(New System.Uri("http://rss.msnbc.msn.com/id/3032091/device/rss/rss.xml"))
Image1.ImageUrl = rss.Channel.Image.Url
GridView1.DataSource = rss.SelectItems()
GridView1.DataBind()
End Sub

The errors are: "Type 'Rss.Toolkit.RssDocument' is not defined. " the fixes include changing it to a RssDatasource , a GenericRssElement, a RssBuildProvider, a RssCodeGenerator or a RssDataSourceView. I have tried converting it to a DataSource and to a hyper link (not one of the fixes, but it came up as an option) but I can NOT get it to work in VB. I could really use some help on this...

Thanks,

Coleen