...Technology Simplified

Friday, June 8, 2012

How to display rss feed in asp.net

No comments :
In this post I will show you how to display rss feed in asp.net using XmlDataSource and DataList control.
Create a web page name it as RSSFeed.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<form id="form1" runat="server">
<asp:TextBox ID="txtUrl" runat="server" Width="349px"></asp:TextBox>
<asp:Button ID="btnLoad" runat="server" Text="Load" OnClick="btnLoad_Click" />
<asp:DataList ID="dlRss" runat="server">
<%#XPath("title") %>
<%#XPath("description") %></i> <i>
<%#XPath("pubdate") %></i> <b><a href="<%#XPath("link") %>">
<%#XPath("link") %></a></b>
<asp:XmlDataSource ID="xml" runat="server" XPath="rss/channel/item"></asp:XmlDataSource>
protected void btnLoad_Click(object sender, EventArgs e)
if (txtUrl.Text != "")
xml.DataFile = txtUrl.Text;
dlRss.DataSourceID = xml.ClientID;

No comments :

Post a Comment