Read xml file attributes within two elements



I have the following xml file and I am trying to get the attribute value which is inside two elements.


XML:



<Processing>
<Aggregation method="summation"/>
<Interpolation method="linear" />
</Processing>


C#:



XmlDocument doc = new XmlDocument();
doc.Load(xmlFile);
XmlNodeList elemNode = doc.GetElementsByTagName(Aggregation );
for (int y = 0; y < elemNode.Count; y++)
result = elemNode[y].Attributes[method].Value;


The following code return an empty string instead of summation.


No comments:

Post a Comment