I want to select a node where inner text of cat is 'PG' using XPath
<?xml version="1.0" encoding="utf-8"?>
<Students>
<student>
<name>Talha</name>
<cat>PG</cat>
</student>
<student>
<name>irfan</name>
<cat>UG</cat>
</student>
<student>
<name>Ali</name>
<cat>PG</cat>
</student>
<student>
<name>Umer</name>
<cat>UG</cat>
</student>
</Students>
Code which I tried is this
XmlElement xmldoc = (XmlElement)doc.DocumentElement
.SelectSingleNode("/Students/student/*[*[local-name()='cat']='PG']");
local-name()call? That's suspicious. You don't need that unless your actual XML has namespaces, and even then you don't really need it. So... does your actual XML have namespaces? If yes, show your actual XML. If not, get rid oflocal-name().