views:

152

answers:

1

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.

A: 

//*[@attr1='1']/@attr1

should do the trick.

remi bourgarel
I'm sorry to say it doesn't :(No errors. Always returns nothing.
Apeksha
I added "//" , i just tried it with cook top and it's ok :)
remi bourgarel