<String>
<Object>
<Name>Whatever</Name>
</Object>
</String>
<Array>
<Name>Max</Name>
<Dimsize>8</Dimsize>
<Cluster>
<Name>Maximums</Name>
<NumElts>3</NumElts>
<U16>
<Name>Max</Name>
<Val>0</Val>
</U16>
<U16>
<Name>Max</Name>
<Val>0</Val>
</U16>
<U16>
<Name>Max</Name>
<Val>0</Val>
</U16>
</Cluster>
<Cluster>
<Name>Maximums</Name>
<NumElts>3</NumElts>
<U16>
<Name>Max</Name>
<Val>0</Val>
</U16>
<U16>
<Name>Max</Name>
<Val>0</Val>
</U16>
<U16>
<Name>Max</Name>
<Val>0</Val>
</U16>
</Cluster>
<Cluster>
<Name>Maximums</Name>
<NumElts>3</NumElts>
<U16>
<Name>Max</Name>
<Val>0</Val>
</U16>
<U16>
<Name>Max</Name>
<Val>0</Val>
</U16>
<U16>
<Name>Max</Name>
<Val>0</Val>
</U16>
</Cluster>
</Array>
Hi,
I have an XML string above and I would like to parse its data into array[item].
As you can see, there are three Cluster node. I want to iterate through the XML text and store the content inside Cluster to Array item[0], item[1] and item[2].
I have the following code so far but it only print out the data from the first node only. How can I get all the data from the remaining node?
var xmlStr = File.ReadAllText("myxml.xml");
var str = XElement.Parse(xmlStr);
for (int i = 0; i < 3; i++)
{
var txt = str.XPathSelectElement("Array/Cluster");
var values = txt.Value;
Console.WriteLine(values);
myChannelArray[i] = values;
}