Tuesday, April 22, 2003 12:48 PM Jan Tielens

How to get a RSS feed in a DataSet in 1 line...

Working with XML is very cool in .NET! With only one line of code, you can get the contents of a RSS feed into a DataSet:

myDataSet.ReadXml(New IO.StreamReader(System.Net.WebRequest.Create("http://msdn.microsoft.com/rss.xml").GetResponse.GetResponseStream))

If you don't like the condensed way of writing you can do it like this too:

Dim wr As System.Net.WebRequest = System.Net.WebRequest.Create("http://msdn.microsoft.com/rss.xml")
Dim sr As New System.IO.StreamReader(wr.GetResponse.GetResponseStream)
myDataSet.ReadXml(sr)

This is great for having all the cool posts on DotNetWebLogs or the new articles on MSDN on your own site.

Comments

# re: How to get a RSS feed in a DataSet in 1 line...

Monday, May 05, 2003 1:15 AM by Dana Coffey

Don't forget to add a second dataset with the column schema matching your xml elements. Then you can merge the two. AND don't forget caching the results so as not to put too big a burden on the rss server :)

# re: How to get a RSS feed in a DataSet in 1 line...

Wednesday, January 07, 2004 4:29 AM by Ian Blackburn

Or just the following will do the same too:

myDataSet.ReadXml("http://msdn.microsoft.com/rss.xml")