I have a XML file that I'm reading as a string and then searching into. The problem is that the SelectSingleNode is failing for any non-root node.
To access the <HostName> value, I use
string xmlFile = "<?xml ..............................."; //Has the XML data
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlFile);
XmlNode test = root.SelectSingleNode("//config:HostName", nsmgr);
Console.WriteLine(test.InnerText);
The above works and prints out "test123" but if I want to select <NIC0><Name>, what do I write? The below failed:
XmlNode test = root.SelectSingleNode("//config:NIC0/Name", nsmgr);
My XML is:
<?xml version="1.0" encoding="utf-16"?>
<Configuration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/ConfigSchema.xsd">
<ConfigVersion>V2.0</ConfigVersion>
<ConfigHash>E9D9A</ConfigHash>
<HostName>test123</HostName>
Bookmarks