XPath select an attribute based on value
Posted
by Apeksha
on Stack Overflow
See other posts from Stack Overflow
or by Apeksha
Published on 2010-03-26T15:47:55Z
Indexed on
2010/03/26
15:53 UTC
Read the original article
Hit count: 363
Using VB.Net,
I have an XmlNode object, xNode.
I need to select an attribute of this node if it has a particular value.
e.g. xNode.SelectSingleNode(".[@attr1='1']")
I would expect this statement to return the attribute "attr1", only if it has a value of "1". However, I get an error - Expression must evaluate to a node-set.
When I tried this - xNode.SelectSingleNode("@attr1[@attr1='1']")
It always returns Nothing, even if the attribute has a value of 1.
I have tried a lot of different things, but no luck yet.
Please help. Thanks.
© Stack Overflow or respective owner