Illustrated in the below image is a flow where the XML Reader step is used to read data from an XML file and convert it into JSON, the Filter step is used to filter for specific data requirements and a Buffer destination step to store the data in.
Adding an XML Reader
To use an XML Reader step in a flow, follow the instructions below:
Click on the highlighted icon as shown in the below image.
2. The below page will appear. Select or search for a Reader step to pull out the source data. Click on the Reader tab and select XML as shown in the image below.
Configure an XML Reader step
The image below illustrates the configuration in the XML Reader step. The XML Reader step has Headers, Field, and Footers sections which have similar configurations. The Field section is open by default when the XML Reader step is added to a flow. To add a Header or Footer configuration, click on the ‘plus’ button as highlighted in the image below.
The configurations that are found in each of the sections are explained below.
Base XPath – This is used to determine the path in the XML file where the information should be fetched from.
Name – This is used to determine the name that will be used for the field.
Mappings – This is used to determine the fields that are being mapped from the XML file. To add a field to map, click on the ‘plus’ button as highlighted in green in the image below. The mappings are added or removed by clicking on the tick or ‘x’ buttons as shown in the image below.
The Mappings configuration table contains the following columns that must be set.
From Path – The Path in the XML where data will be fetched from.
To Path – The Name of the path to store the data when it is fetched from the XML file.
Type – The data type. This could be a String, Number, Boolean or any other data type required. Select the required from the dropdown list.
Ignore if Not Present checkbox – This will exclude a field if it is not present, or it will set the value to ‘null’ when the box is checked.
Force Null checkbox – This will set the value to ‘null’ when the box is checked.
Merge Attributes Checkbox – Merge attributes to an object. The checkbox is selected by default when the XML Reader step is added.
Explicit Array Checkbox – Always puts child nodes in an array if true. Otherwise, an array is created only if there is more than one. The checkbox is not selected by default when the XML Reader step is added.
Convert Values Checkbox – Automatically converts Boolean and number values. The checkbox is selected by default when the XML Reader step is added.
Using an XML Reader step
To use an XML Reader step, follow instructions below:
Click on the play button on the XML Reader step as highlighted in the image below:
2. Click the highlighted are in the image below to upload an XML file.
3. Click the Test button as shown in the image below.