Attention: We are retiring the ASP.NET Community Blogs. Learn more >

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.

1 Comment

  • 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 :)

Comments have been disabled for this content.