Eduardo Lorenzo
Well-known member
- Joined
- Jun 27, 2006
- Messages
- 86
At the moment, I have a side-task of reading an XMLFile that looks like this:
there is an unlimited/unpredictable number of headeritem nodes and Table1 nodes.
The task is to create one BulletedList (DisplayMode = Hyperlink) object per headeritem with headeritems <text> and <url> values as the Text and URL as the link. And then go through all the Table1 nodes and populate each BulletedList with the Text and url nodes/values per list.
this is what I have presently:
but it selects only the first node???
All help will be greatly appreciated. Thank you.
<headerItem>
<text>Header 1</text>
<url>header1s url goes here</url>
<Table1>
<Text>HeaderItem 1</Text>
<url>headerItem 1s url goes here</url>
</Table1>
<Table1>
<Text>HeaderItem 2</Text>
<url>headerItem 2s url goes here</url>
</Table1>
</headerItem>
there is an unlimited/unpredictable number of headeritem nodes and Table1 nodes.
The task is to create one BulletedList (DisplayMode = Hyperlink) object per headeritem with headeritems <text> and <url> values as the Text and URL as the link. And then go through all the Table1 nodes and populate each BulletedList with the Text and url nodes/values per list.
this is what I have presently:
Code:
protected void xPathLoad()
{
XmlDocument d = new XmlDocument();
d.Load(Server.MapPath("/My_Page/App_Data/footer.xml"));
foreach (XmlNode header in d.SelectNodes("//headerItem"))
{
BulletedList footerList = new BulletedList();
footerList.DisplayMode = BulletedListDisplayMode.HyperLink;
string headerText = header.SelectSingleNode("//text").InnerText + "header ";
string headerURL = header.SelectSingleNode("//url").InnerText;
footerList.Items.Add(new ListItem(headerText,headerURL));
foreach (XmlNode items in header.SelectNodes("//Table1"))
{
string itemText = items.SelectSingleNode("//Text").InnerText;
string itemURL = items.SelectSingleNode("//url").InnerText;
footerList.Items.Add(new ListItem(itemText, itemURL));
}
this.Controls.Add(footerList);
}
but it selects only the first node???
All help will be greatly appreciated. Thank you.