Read From XML

The Read from XML stage reads an XML file into a job or subflow. It defines the file's path and data format, including XML schema and data element details.

Simple XML elements are converted to flat fields and passed on to the next stage. Simple XML data consists of records made up of XML elements that contain only data and no child elements. For example, this is a simple XML data file:

<customers>
    <customer>
        <name>Sam</name>
        <gender>M</gender>
        <age>43</age>
        <country>United States</country>
    </customer>
    <customer>
        <name>Jeff</name>
        <gender>M</gender>
        <age>32</age>
        <country>Canada</country>
    </customer>
    <customer>
        <name>Mary</name>
        <gender>F</gender>
        <age>61</age>
        <country>Australia</country>
    </customer>
</customers>

Notice that in this example each record contains simple XML elements such as <name>, <gender>, <age>, and <country>. None of the elements contain child elements.

The Read from XML stage automatically flattens simple data like this because most stages require data to be in a flat format. If you want to preserve the hierarchical structure, use an Aggregator stage after Read from XML to convert the data to hierarchical data.

Complex XML elements remain in hierarchical format and are passed on as a list field. Since many stages require data to be in a flat format, so you may have to flatten complex XML to make the data usable by downstream stages. See Flattening Complex XML Elements for more information.

Note: Read From XML does not support the XML types xs:anyType and xs:anySimpleType.

Read from XML Options

Option Name

Description

Data file

Specifies the path to the XML data file. Click the File icon to locate the file you want.

Note: If the Spectrum Technology Platform server is running on Linux, remember that file names and paths on these platforms are case sensitive.

Schema file

Displays the path of the selected XML Data file. To select any other file, click the File icon and locate the required XML file. In this case, the schema is inferred based on the structure of the selected XML file.

Alternatively, you can select a schema (XSD) file from the list. When you select an XSD file, the Validate against schema toggle is displayed. Select Yes to validate the XML data file against the selected schema.

Note: If the Spectrum Technology Platform server is running on Linux, remember that file names and paths on these platforms are case sensitive.
XPath Displays the XPath expression for the element or attribute. It is displayed for information purposes only. For more information about XPath, review this page.

Preview

Displays a preview of the schema or XML file. When you specify an XSD file, the tree structure reflects the selected XSD. Once you specify both a schema file and a data file, you can click on the schema elements to have a preview of the data that the element contains.

Apply Click this button on the top of the page to save your stage settings.