I tried but could not get it? Here is the xml file
<Root>
<Data>
<Keys>Key1, key2, key3, key4</Keys>
<FirstRow>Key1row1, Key2Row1, Key3Row1, Key4Row1</FirstRow>
<SecondRow>Key1Row2, Key2Row2, Key3Row2, Key4Row2</SecondRow>
<ThirdRow>Key1Row3, Key2Row3, Key2Row3, Key2Row3</ThirdRow>
and so on .........
</Data>
</Root>
I need to use Linq to XML:-
var data = from d in xDoc.Root.Element("Data")
select d;
foreach(var d in data)
{
...
}
I like to have a M-d array mapping of comma separated keys value with is comma separated Rows values.
Key1 key2 key3 key4
Key1row1 key2Row1 Key3Row1 Key4Row1
....
The row elements can be iterated (as done), but it’ll take
string.Split(or a more advanced parser) to decompose the row values themselves. In the following example it is done in theRowTextToValuesmethod.Here is a LINQPad example (run as “C# Program”) with some hints:
Converting to an 2-dimensional array or handling more complex rules is left as an exercise.