Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Sunil Garg   on Oct 18 In Asp.net Category.

  
Question Answered By: Geraldine Perkins   on Oct 18

Speaking of the XmlTextReader, check out my latest article:

Consuming an RSS Feed with ASP.NET
aspnet.4guysfromrolla.com/articles/031903-1.aspx

The above article shows how to consume an RSS feed (which contains
syndicated content for a Web site in XML format) and display the RSS
data in a DataGrid. When I first sat down to write this code I thought
it would be several lines long - I was very wrong. The entire code
section is like 10 lines long, and that includes CACHING the data,
reading the remote XML data, and binding it to a DataGrid!

This brevity is due in large part to the XmlTextReader. I can populate
the XmlTextReader with remote XML in one line of code:

Dim reader as XmlTextReader = New
XmlTextReader("http://www.yoursite.com/rss.xml")

And then dump it into a DataSet in two lines of code:

Dim ds as DataSet = New DataSet()
ds.ReadXml(reader)

And then display it in a DataGrid in another two lines of code:

datagridID.DataSource = ds.Tables(2)
datagridID.DataBind()

It's that simple! Some other worthwhile articles that deserve a look
are:

XML, the DataSet, and a DataGrid
aspnet.4guysfromrolla.com/articles/052902-1.aspx

which essentially looks at displaying XML data in a DataGrid,

DataGrids, DataSets, and XML Strings
aspnet.4guysfromrolla.com/articles/071702-1.aspx

which looks at dumping the contents of a DataGrid out to XML. There are
also articles at http://aspnet.4guysfromrolla.com/ that show how to use
cache dependencies to cache XML data that is being displayed in a
DataGrid, that expires whenever the underlying XML data store is
altered. Neat, neat stuff.

<shameless plug>
For more information on the DataGrid, DataList, and Repeater controls,
consider picking up a copy of my latest book:

ASP.NET Data Web Controls
www.amazon.com/.../4guysfromrollaco
</shameless plug>

Share: