I am parsing some XML. I am iterating over 2 Pit
nodes and trying to find out their x
node value.
My problem: When I inspect each Pit
nodes x
value its always says value is 8
, when the second nodes x
value is actually 1
.
Why is this happening and how can I fix it?
XmlNodeList xNodes = xdoc.DocumentElement.SelectNodes("//ns:pits", nsmgr);
foreach (XmlNode pit in xNodes) {
XmlNode x = pit.SelectSingleNode("//ns:x", nsmgr);
MessageBox.Show(x.InnerText, ""); // Always prints "8", when 1 should be "8", another "1"
}
The data I am using:
<?xml version="1.0"?>
<xml12d>
<pit>
<x>8.89268569</x>
<y>1.26122586</y>
<z>1.62414621</z>
</pit>
<pit>
<x>1.09268598</x>
<y>7.24091243</y>
<z>8.20896044</z>
</pit>
</xml12d>