XML Reader Task

XML Reader transforms an XML content into a simple object available inside your workflow. Optionally, you can iterate over the results of an XPath expression.

Note: since attributes are specific to an XML format, a special entry ‘attributes’ will be available for each transformed element.

main

Input file path
If your xml data is a file, provide the complete path which end with ‘.xml’.

XML string
You can either provide a valid quoted xml string, or an existing variable containing your xml data.

Iterate over XPath results
Executes the provided XPath expression, and iterates over transformed results.

Sample usage

Imagine that you are reading XML data describing promos to generate and you want to iterate over all elements.

sample1

XML string value

This is the source XML you received:

<batch id="65E2-7049-9381">
    <promos>
        <promo index="1">
            <id>029872_141521</id>
            <queue_id>97370</queue_id>
            <datepromo>14-02-2017</datepromo>
            <duration>30:01</duration>
            <delivery>
                <deliver>INTERPLAY</deliver>
            </delivery>
        </promo>
        <promo index="2">
            <id>other_id</id>
            <queue_id>97370</queue_id>
            <datepromo>14-02-2017</datepromo>
            <duration>20:01</duration>
            <delivery>
                <deliver>INTERPLAY</deliver>
            </delivery>
        </promo>
    </promos>
</batch>

Using XPath

To find and iterate over all promos contained in the xml data, we will use the following XPath expression, surrounded with quotes: "/batch/promos/promo"

To find directly a promo with a specific id value, use: "/batch/promos/promo[id="other_id"]"

To find the promo with the “index “ attribute 2, use: "/batch/promos/promo[@index="2"]"

Message value is set to

For each promo found, we’ll display id in a task message.
"value for tag ID index {}: {}".format(loop_index, loop_value.id.value) sample2

Remember that: