I have the following XML.
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://localhost/gsainis/GsaInisWebService">
<string>
<gsafeed>
<group action="add">
<record>
......
......
</record>
</group>
</gsafeed>
</string>
</ArrayOfString>
I am using C# code (.NET 4.0) to parse this XML. I am using the code below to select all <record> nodes in the above XML.
XmlNamespaceManager xmlnsmgr = new XmlNamespaceManager(INISRecordXMLdoc.NameTable);
xmlnsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
xmlnsmgr.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
xmlnsmgr.AddNamespace(string.Empty, "http://localhost/gsainis/GsaInisWebService");
foreach (XmlNode node in INISRecordXMLdoc.SelectNodes("//ArrayOfString/string/gsafeed/group/record",xmlnsmgr))
{
//Do something
}
The problem is the foreach loop is never executed. What should be correct XPath to be used such that I get all the <record> nodes?