Problem with XML elements

I have a problem with extracting data from XML elements and write them in an excel file.

Here is the XML.

IOM_XML_Utkast.docx (16.2 KB)

ill have a For Each where i iterate through the elements and extracts the data and write it in Excel.

Now to the problem. There is 2 Legs and i can only fetch the data from 1 Leg (the second Leg)

How can i fetch the data from both Legs?


we cannot see the deatils of your xml. Maybe you can share the sample xml file, a screenshot or using the editor format option </>

One important question is, if the XML is defining namespaces.

lets assume the xml looks like this in the structure:

  • root
    • leg
      • e1
      • e2
    • leg
      • e1
      • e2

retrieve all legs with xDoc.Root.Descendants(“leg”).toList - retuned: List(Of XElement) xeLegs

iterate over xeLegs within a for each and setup the element retrieval ( in this demo: e1,e2)

also have a look here:

1 Like

@ppr I have updated my post with the XML.

Thank you for your swift response


I assume the fragment is surrounded by a root element (otherwise we can inject / fix it, before parsing)

As written above: the xDoc.Root.Descendants(“Legs”).toList will help for the iteration.

Let us know your open questions


thank you. Now i got an error.

XML error.docx (365.3 K

better is, to help us on native languguage error messages that we can understand.

It looks like leglist is of datatype XElement but should be of datatype List(Of XElement) as we do expect many legs

Sorry for the language error. But you solved my problem anyway :slight_smile:

I dont really understand how i should iterate through the Leglist using your demo.

sorry for my endless questions. Im a newbie on robotics :slight_smile:

give me a liitle time an will do some helper for you

Of course…


Parsing & Legs retrieval:



find starter help:
XMLDescendantsDemo.xaml (7.2 KB)

Sample XML:
DescendantsDemo.xml (636 Bytes)

Kindly note: the xml has to be valid and requires a root element, In the sample XML the root was manually added

Could not find type ‘DeserializeXml’ in namespace ‘’. Row: 61, Column: 6
which package should I have to install peter ?


1 Like

Absolutely brilliant. Thank you.


Can you please elaborate your String. I dont know how to break it down in order to transfer the data to an Excel sheet.

String.Format(“Leg: {0} # Element: {1} # Value: {2}”,idx.toString,,item.Value)

From output:
Leg: 0 # Element: CarrierCode # Value: QR ( how can i transfer this data to a specific cell)


in general do following:

  • define a datatable structure with the columns: legID, Key, Value - Build Datatable activity

  • additional to the logging use add datarow activity and define for rowArray: new Object(){dx.toString,,item.Value}

  • the resulting datatable can be written to Excel with write range activity

Have also a look on the provided links / referenced posts as well.

In case of you need more individual help for your case, please share follwoing with us:

  • detailed descriptions of the resulting output (e.g. an excel with sample data)
  • how the dynamics should be handled (1…n legs, 1…n leg child elements)


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.