I've an XML document like this:
<Columns>
<Column>
<Name>A</Name>
<Width>100</Width>
</Column>
</Columns>
<Columns>
</Columns>
<Columns>
<Column>
<Name>C</Name>
<Width>300</Width>
</Column>
<Column>
<Name>C1</Name>
<Width>310</Width>
</Column>
</Columns>
I'm getting their Name and Width text and store them a List.
var man = new XmlNamespaceManager(xdoc.NameTable);
man.AddNamespace("ns", "http://schemas.microsoft.com/project");
List <string> lstText = new List<string>();
List <List<string>> lst = new List<List<string>>();
XmlNodeList xnList = xdoc.SelectNodes("/ns:Columns/ns:Column", man);
foreach (XmlNode xn in xnList)
{
lstText.Add(xn["Name"].InnerText));
lstText.Add(xn["Width"].InnerText));
}
lst.Add(lstText);
So, I can only get these values: A and 100, C and 300. I want to get C1 and 310 too. How can I get them?
Edit: Some of Columns has no Column, some of Columns has 1 or more Colums. In this sample, my List has 3 elements:
lst[0][0] = {A, 100}
lst[1][0] = null
lst[2][0] = {C, 300}, lst[2][1] = {C1, 310}