I am facing some problem in getting the attribute values from a xml file using C#. I have attached the code snippet.
My program accepts an input structure from an xml file (see attachment). It parses the file and then gets all the column names that is in turn used to create columns in Grid view control. The issue is... I am not able to get the column names if the node has some sub nodes.
In the attached xml file, you can see the <member Name"elemDesc" type="unsigned int"> has one or more sub nodes <Value></Value>. In this case the column names are not getting displayed.
But works fine if the node does not have any sub nodes as in <member Name = "Type" type = "unsigned int" />
I am sure the problem lies in the expression passed. Please help me resolve this issue. without this I will not be able to proceed with my work comfortable :(
private void ReadInputStructure(ref List<string> Items, string deviceName)
string fileName = "D:\\Ultrasound\\Initiatives\\StructureInput.xml";
XPathDocument doc = new XPathDocument(fileName);
XPathNavigator nav = doc.CreateNavigator();
// Compile a standard XPath expression
expr = nav.Compile("/devices/device[@Name=\"" + deviceName + "\"]/member");
XPathNodeIterator iterator = nav.Select(expr);
XPathNavigator nav2 = iterator.Current.Clone();
string ColumnName = nav2.GetAttribute("Name", nav2.NamespaceURI);