Using VB.Net,
I have an XmlNode object开发者_StackOverflow社区, 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.
//*[@attr1='1']/@attr1
should do the trick.
精彩评论