How to bind this XML data?

S

Shapper

Hello,

I have a XML which contains 2 data types:
1. Data which is not repeated. (<title>, <link>)
2. Repeating data. (<item>)

My XML File:
<channel>
<title>...</title>
<link>...</link>
<item>
<title>4 Web Version 1.0 is available since today!</title>
<link></link>
<description>...</description>
<pubDate>...</pubDate>
</item>
...

I was able to place data in (1) in the HeaderTemplate of my Repeater.

Now I need to place the repeating data in the ItemTemplate of my
Repeater.

I have this:
news.Load(Server.MapPath("xml/news.rss"))
rptNews.DataSource = news.SelectNodes("channel/item")
rptNews.DataBind()

It's not working. When I use <%# DataBinder.Eval(Container.DataItem,
"title") %> in my aspx code I get the error: DataBinder.Eval:
'System.Xml.XmlElement' does not contain a property with the name title.

I suppose I need to get the XML data into a dataset and then bind it to
my repeater. Is that right?

How can I solve this?

Thank You,
Miguel
 
G

Guest

Oh, sorry. I think that code in my first post had a bug.
It should have been:

<%#((System.Xml.XmlNode)Container.DataItem).SelectSingleNode("title").InnerText %>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top