XPath: select node based on other node's value



Suppose I have a list of items, each with its own <id> element. There is also a <primaryId> element (outside mentioned list) specifying which one of these items is 'primary'. How do I select 'primary' item's <value> element? Is it possible to do using XPath in .Net?


The result in the following example should be <value>val2</value>.



<root>
<primaryId>2</primaryId>
<items>
<item>
<id>1</id>
<value>val1</value>
</item>
<item>
<id>2</id>
<value>val2</value>
</item>
</items>
</root>

No comments:

Post a Comment