Skip to main content

XML Parse Tool XML Parse Tool

One Tool Example

XML Parse has a One Tool Example. Go to Sample Workflows to learn how to access this and many other examples directly in Alteryx Designer.

Use XML Parse to parse Extensible Markup Language (XML) into individual fields. Go to Reading XML for more information on how Alteryx reads and parses XML.

Important

If the XML contains namespaces like w:document, the namespace is stripped in the output and w:document is returned.

Configure the Tool

  1. Select the Field with XML Data that you want to parse. Select from the string fields included in your input.

  2. Use Include in Output (checked by default) to determine whether or not to pass the parsed field downstream when the workflow runs.

  3. Select the XML Element to Parse. Options include...

    • The Root element.

    • Auto Detect Child: Parse out the element that is a child to the element in the input data—an alternative to specifying which element of the XML to parse. The element that occurs the highest number of times under a single parent node is the element that is parsed.

    • Specific Child Name: Enter the name of the child element to parse out. The XML element is case-sensitive.

  4. Select these additional options:

    • Return Child Values: Check to return the 1st set of child values. Uncheck to leave out child values.

    • Return Outer XML: Check to return the outer XML tags. This creates an additional field for each parsed field with the suffix _OuterXML. The tags are included around the values in the data table.

    • Ignore XML Errors and Continue: Ignore any errors that are produced by the XML and continue parsing.

How Auto Detect Child Works

The element that occurs the highest number of times under a single parent node is the element that is parsed. If no element occurs more than once, then the default is simply to select the 1st child of the root.

Example

In the code example...

  • The record element is auto-detected because it occurs 3 times under a single parent node.

  • The root and firstchild elements each appear once.

  • The field1, field2, and field3 elements appear 3 times each, but not under a single parent node (they each occur once per parent "record" node.)

   <root>
   <firstchild> 
       <record><field1/><field2/><field3/></record>
       <record><field1/><field2/><field3/></record>
       <record><field1/><field2/><field3/></record>
   </firstchild>
</root>

Important

The Auto Detect Child only takes the 1st row of input into account versus all rows of input. The messages tab on the output of the XML Parse tool should show a message that indicates which element was auto-detected as the default.