XPath node selection
Hi all,
I want to select nodes from a given xml where the nodes have the same values for 2 out of 3 attributes usign XPath. For eg. The xml can have the format:
<root>
<SearchFilter>
<QueryParameters name="BID" value="531,532" by="3" />
<QueryParameters name="LN" value="TEST,Que" by="2" />
<QueryParameters name="GP" value="ERRR" by="3" />
<QueryParameters name="BID" value="539" by="3" />
<QueryParameters name="BID" value="537" by="2" />
</SearchFilter>
</root>
The resultant XmlNodeList should have the node:
<QueryParameters name="BID" value="539" by="3" /> if I need to select name="BID" and by="3".
I used the following command:
XmlNodeList xn1 = srcXDoc.SelectNodes("//QueryParameters[(@name=preceding-sibling::QueryParameters/@name and @by= preceding-sibling::QueryParameters/@by)]");
But the resultant nodelist contains both the nodes:
<QueryParameters name="BID" value="539" by="3" />
<QueryParameters name="BID" value="537" by="2" />
It seems that the second attribute value is not being considered by the XPath. Please let me know the mistake I am committing.
|