05
Dec
2008
0

Consuming RSS feed in ASP.NET

Thanks to RSSToolKit, an open source component you can find at codeplex, consuming a RSS field to display, for instance, in your website has never been so easy.

Here is the code we use to display 3 posts of this blog on the official phoceis.com website (in a literal named lit_blog)

RssDocument rdoc = RssToolkit.Rss.RssDocument.Load(new System.Uri("http://blog.phoceis.com/feed/rss/"));
DataView dv = (DataView) rdoc.SelectItems(3);
lit_blog.Text = "
<ul>";
foreach (DataRow dr in dv.Table.Rows)
{
	lit_blog.Text += "
	<li><a href='" + dr["link"].ToString() + "' target="_blank">" + dr["title"].ToString() + "</a></li>";
}
lit_blog.Text += "</ul>";
Ecrit par julien dans : .NET | Tags : , ,

Propulsé par WordPress | Thème Aeros | TheBuckmaker.com WordPress Themes | Traduction WordPress tuto