I am receiving an xml message like the below (Believe me this is NOT how I want it):
<items>
<item item="A" position="0">
<itemvalue>10</itemvalue>
</item>
<item item="A" position="1">
<itemvalue>20</itemvalue>
</item>
<item item="A" position="2">
<itemvalue>30</itemvalue>
</item>
<item item="B" position="0">
<itemvalue>10</itemvalue>
</item>
<item item="B" position="1">
<itemvalue>20</itemvalue>
</item>
<item item="B" position="2">
<itemvalue>30</itemvalue>
</item>
</items>
I am shredding the XML using LINQ. So what I get is a List of Item | Position | Value. How I really want the data is to match my table structure.
Item | Column1 | Column2 | Column3
A 10 20 30
What is the best way for me to take that List and Build a separate Object I can pass to the DB. Right now I am getting the distinct list of Items (So A & B here) and then passing that into a Lambda expression so that I can say give me the value where Item = A and Position = X (0,1,2).
Just wondering what the best method would be to “flatten” this poorly structured XML.
Read xml and group on
itemattribute.