Good day. I would like to ask how can I get the values for each container without including the same element on other container? See my dummy xml file below:
What I want is to get the containerinfo values and group them according to their parent container element. I tried to implement it but it always get other containerinfo values on different container element. So the result that I want is this:
1st container:
container1, 5000kgs, 20ft
container2, 10000kgs, 15ft
2nd container:
container3, 7000kgs, 20ft
container4, 8000kgs, 15ft
I hope that someone will explain it in details and with step-by-step solution coz it’s been a week since and still I cannot find a solution. Thank you.
First deserialize the xml and say stored in xmlout variable
Use xmlout.Root.Descendants(ifnamspacespresnetaddhere + "Container").ToList
Use for loop with output of step 2 which is of type list of xelement
Inside loop use currentitem.Descendants("ContainerInfo").ToList will give the list of containerinfo again here also you need to add namspace if present
Inside the first loop use second loop for output of step4
Inside the second use currenitem2.element("name").ToString
Hope this helps…if not provide a file of xml can give some more details