Setting up detail tables with XML

Detail tables are created when an Extract step is added within a Repeat step. The Repeat step goes through a number of lines or nodes. An Extract step within that loop extracts data from each line or node.
How exactly this loop is constructed depends on the type of source data.

This topic explains how to set up detail tables when extracting data from an XML file.

How to extract transactional data that is not structured uniformly is explained in another topic: Extracting data with an Action step script.
The topic: Extracting data of variable length explains a few ways to extract data from a variable number of lines into one data field.

For more information about detail tables, multiple detail tables and nested detail tables, see Detail tables.

Creating the loop

In XML files, transactional data appear in repeated elements.

  1. Right-click one of the repeating elements and select Add Repeat.

    This adds a Repeat step to the data mapping configuration.
    By default, the Repeat type of this step is set to For Each, so that each of the repeated elements is iterated over. You can see this on the Step properties pane, as long as the Repeat step is selected on the Steps pane. In the Collection field, you will find the corresponding node path.

    Tip: You may edit the XPath in the Collection field, to include or exclude elements from the loop. One example of this is given in a How-to: XML/JSON loops.
    For an overview of XPath functions, see Mozilla: XPath Functions.
    In addition, it is possible to use JavaScript statements in an XPath in the Collection field to dynamically select elements; see Repeat Definition.

    The Goto step isn't used in XML extraction workflows in most cases. Instead, the cursor can be moved using Xpath, a path-like syntax to identify and navigate nodes in an XML document.

    Note, however, that a relative Xpath is not relative to the boundary statement but rather to the current pointer location, which at first is at the top of the record. In some cases it may be necessary to adjust the current pointer location with a Goto step (Level up/down).

  2. (Optional.) Add an empty detail table via the Data Model pane: right-click the Data Model and select Add a table. Give the detail table a name.

  3. Select the Repeat step on the Steps pane.

  4. Extract the data: inside a repeating element, select the data that you want to extract. Then right-click the selected nodes and select Add Extraction, or drag & drop them in the Data Model.
    When you drag & drop data on the name of a detail table in the Data Model pane, the data are added to that detail table.
    Dropping the data somewhere else on the Data Model pane creates a new detail table, with a default name that you can change later on (see Renaming a detail table).
    The new Extract step will be located in the Repeat step.

Tip: To break out of a loop and immediately jump to the next task following the current loop, use an Action task and set its action to Break out of repeat loop.