Reputation: 81
My XML is as below:
I need to check whether "anil"
is in the DOM or not without using loop. Is it possible to do this in one line?
This is the code I tried:
If not(xmldom.selectsinglenode("//xml/xmlfile/name/"+xname)is nothing) then
.....
end if
Here xname
will be the text (eg anil
or amith
).
Upvotes: 1
Views: 706
Reputation: 89325
The correct XPath to get <name>
element having inner text equals anil
is as follow :
//xml/xmlfile/name[.='anil']
So the string parameter of selectsinglenode()
should look about like this instead (or better yet using /
instead of //
at the beginning) :
"//xml/xmlfile/name[.='"+xname+"']"
Upvotes: 1