Get all values and group them according to parent node xml

we assume the following:

  • no XML namespaces are involved
  • the XML is a snippet (as it doesn’t have a root element)

For starting / more exploration you can do:

Modelling:

Details For each container:
grafik
xDoc.Root.Descendants(“container”)
Log: "Processing: Container with Num: " + item.Element("containernum").Value

Details For each info
grafik
item.Descendants(“containerinfo”)
Log:

String.Format("{0}, {1}.{2} ",info.Element("name").Value, info.Element("weight").Value, info.Element("height").Value)

It will produce the following output:
grafik

Depending on your further processing demands we can also modify / adapt e.g. with the usage of LINQ like:

grafik

When XML Namespaces are involved habe a look here:

1 Like