Home All Groups Group Topic Archive Search About
Author
25 Feb 2006 8:42 PM
Francis
Hello,
    I recently decided to try and consume an rss feed and put it into a
datagrid, just to try it out. I used the following code:

DataSet dsXml = new DataSet();

         XmlReader xmlTr = new
XmlTextReader("http://www.flickr.com/services/feeds/photos_public.gne?format=rss_200");

         dsXml.ReadXml(xmlTr);
         xmlTest.DataSource = dsXml.Tables[0];
         xmlTest.DataBind();

However, i get the error: A column named 'title' already belongs to this
DataTable.
    How would be the best way to get round this? I think it is because an
embedded xml column is called the same name.
    Thank you
    Francis

Author
27 Feb 2006 1:01 PM
W.G. Ryan - MVP
Use an XSLT transform to do accompish this. I believe you just need to add a
node above Title and that should do it.  BTW, NSoftware has a pretty cool
RSSDataAdapter you may want to check out... www.nsoftware.com

Show quote
"Francis" <f@f.com> wrote in message
news:%23aLt1vkOGHA.2300@TK2MSFTNGP15.phx.gbl...
> Hello,
> I recently decided to try and consume an rss feed and put it into a
> datagrid, just to try it out. I used the following code:
>
> DataSet dsXml = new DataSet();
>
>         XmlReader xmlTr = new
> XmlTextReader("http://www.flickr.com/services/feeds/photos_public.gne?format=rss_200");
>
>         dsXml.ReadXml(xmlTr);
>         xmlTest.DataSource = dsXml.Tables[0];
>         xmlTest.DataBind();
>
> However, i get the error: A column named 'title' already belongs to this
> DataTable.
> How would be the best way to get round this? I think it is because an
> embedded xml column is called the same name.
> Thank you
> Francis
Author
28 Feb 2006 12:47 AM
blackstaronline.net
Here is some code that I am using to consume RSS feeds it works great.
If you want to see it, I wrote an article on consuming an rss feed
Heres the link: http://hgtit.com/article.aspx?ID=46


<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<script language="VB" runat="server">
  Sub Page_Load(sender as Object, e as EventArgs)
    If Cache("RSSfeed") Is Nothing then
    'Item not in cache, go and get it
    Dim dt as DataTable =
GetRSSFeed("http://rss.news.yahoo.com/rss/world")
    Cache.Insert("RSSfeed", dt, Nothing, DateTime.Now.AddMinutes(60),
TimeSpan.Zero)
    End If

    dlRSSData.DataSource = Cache("RSSfeed")
    dlRSSData.DataBind()

  End Sub


  Function ReadRSS(strRSSURL as String) as DataTable
    Dim XMLreader as XmlTextReader = New XmlTextReader(strRSSURL)

    Dim objds as DataSet = New DataSet()
    objds.ReadXml(XMLreader)
    Return ds.Tables(3)
  End Function
</Script>
<html>
<body>
<form runat="server">

<asp:DataList runat="server" id="dlRSSData">
<itemtemplate>

<a href="<%# DataBinder.Eval(Container.DataItem, "Link") %>"
target="_blank">

<%# DataBinder.Eval(Container.DataItem, "title") %></a><br />

<%# DataBinder.Eval(Container.DataItem, "description")%><br /><br />

</itemtemplate>
</asp:DataList>

</form>
</body>
</html>

AddThis Social Bookmark Button