Let's say there is a blog
spot as http://xxxxxx.blogspot.com then RSS feed data would be available at
http://xxxxx.blogspot.com/rss.xml. So this is the source data for us to work
with.
Now start with code part:
1. First
lets add DataGrid to our web page, with one template column as shown below
<asp:DataGrid runat="server"
ID="myPosts"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="My
Posts">
<ItemTemplate>
<a href="<%#
DataBinder.Eval(Container.DataItem, "link")%>">
<%# DataBinder.Eval(Container.DataItem, "title") %>
</a>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
2.
In our page load, lets declare XMLTextReader object & this will take RSS
FEED URL. In this example I am using my blogspot url
XmlTextReader reader = new XmlTextReader("http://bgsuryablog.blogspot.com/rss.xml");
3.
We will declare Dataset
DataSet ds = new DataSet();
4.
To read XML data & read into DS lets use below code
ds.ReadXml(reader);
5. As we
have dataset object filled up with RSS feed data. Lets assign Dataset to
datagrid as below
myPosts.DataSource = ds;
myPosts.DataBind();
6. Dataset
object would contain properties in the form of Link & Title, which we have
used in our .aspx code i.e. step1
Join the conversation! Your thoughts help the community grow.