Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XPath to select sub-node
Message
From
26/06/2007 07:04:15
 
 
To
All
General information
Forum:
ASP.NET
Category:
XML
Title:
XPath to select sub-node
Environment versions
Environment:
C# 2.0
OS:
Vista
Miscellaneous
Thread ID:
01235567
Message ID:
01235567
Views:
62
If I have an XML structure like this:
<group>
  <items>
    <item />
    <item />
  </items>
</group>
<somethingelse>
  <items>
    <item />
    <item />
  </items>
</somethingelse>
I have loaded the XML doc and created an XmlNodeList like:
XmlNodeList groupNodeList = xml.SelectNodes(//group);
If I then iterate through the groups and attempt to move through the items in that group, I am picking up all items, not just the ones in that group.
foreach (XmlElement groupNode in groupNodeList)
  XmlNodeList = groupNode.SelectNodes(//item);
it works if I do this
  XmlNodeList = groupNode.SelectNodes(//group//items//item);
obviously the groupNode is not what I think it is - what am I doing wrong here?
- Craig

"If you're not prepared to be wrong, you will never come up with anything original."
- Sir Ken Robinson
Next
Reply
Map
View

Click here to load this message in the networking platform