Relative XPath selection using XmlNode (c#)

Posted by maxp on Stack Overflow See other posts from Stack Overflow or by maxp
Published on 2010-05-13T10:54:54Z Indexed on 2010/05/13 11:04 UTC
Read the original article Hit count: 296

Filed under:
|

Say i have the following xml file:

<a>
  <b>
    <c></c>
  </b>
  <b>
    <c></c>
  </b>
</a>

var nodes = doc.SelectNodes("/a/b");

will select the two b nodes.

I then loop these two nodes suchas:

 foreach (XmlNode node in nodes) { }

However, when i call node.SelectNodes("/a/b/c"); It still returns both values and not just the descendants. Is it possible to select nodes only descening from the current node?

© Stack Overflow or respective owner

Related posts about c#

Related posts about xpath