xpath - How to check the node with certain text exists in XML dom? -


my xml below.

enter image description here

here need check whether "anil" there in "dom" or not without using loop. , query in 1 line. possible? code tried :

if not(xmldom.selectsinglenode("//xml/xmlfile/name/"+xname)is nothing)     ..... end if 

here xname text (eg anil or amith).

the correct xpath <name> element having inner text equals anil follow :

//xml/xmlfile/name[.='anil'] 

so string parameter of selectsinglenode() should instead (or better yet using / instead of // @ beginning) :

"//xml/xmlfile/name[.='"+xname+"']" 

Comments