For example, CodeDigest Rss feed will look like,
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
<title>CodeDigest.com Latest Articles</title>
<link>http://www.codedigest.com</link>
<description>Latest articles hosted on
CodeDigest.com.</description>
<item>
<title>Useful Datagrid Tips</title>
<description>There are some frequent queries that
are being asked in most of the forums and UG’s regarding datagrid. I have
compiled a list of useful tips from my previous posts and posted it
here.</description>
<link>http://www.codedigest.com/Articles/ASPNET/77_Useful_Datagrid_Tips.aspx</link>
<pubDate>4/29/2008 9:47:12 AM</pubDate>
</item>
</channel>
</rss>
As we can see the above XML the whole contents is packed
inside <rss> tag. The actual information about the posts is kept inside
<item> tag which in turn is packed inside a <channel> tag. Read the
history(http://en.wikipedia.org/wiki/RSS_(file_format))
and specification of RSS here(http://blogs.law.harvard.edu/tech/rss )
Binding RSS feed to DataList
This can be done using DataSet object ReadXml() method
XmlTextReader Object.
XmlTextReader reader = null;
try
{
reader = new
XmlTextReader("http://www.codedigest.com/Articles/Rss.ashx");
DataSet ds = new DataSet();
ds.ReadXml(reader);
dlRSS.DataSource = ds.Tables["item"];
dlRSS.DataBind();
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
}
finally
{
reader.Close();
}
|