Mapper
Extracts a value or a list of values from an XML text or an XML file with an XPath expression.
The Mapper action in the XML folder reads an XML text or an XML file and returns what an XPath expression selects. When the expression matches one node you get a single value; when it matches several you get a list. Is List tells you which one you got.
Mapper was previously called XML Mapper.
Add the action
In the Process Designer toolbox, open XML and pick Mapper (or type Mapper in the search box).

Inputs and outputs
| Field | Direction | Type | Required | What to put / what you get |
|---|---|---|---|---|
| Input XML | Input | Text | No* | The XML as text. |
| Input XML file | Input | File | No* | An XML file. Used only when Input XML is empty. |
| XPath Expression | Input | Text | Yes | The XPath that selects what you need, for example /bookstore/book[1]/title. |
| Is List | Output | Boolean (true/false) | Yes | true when the expression matched more than one node, false otherwise. |
| The resulting value | Output | Any type | No | The content of the matched node, when exactly one node matched. |
| The resulting list of values | Output | List of any type | No | The content of every matched node, when more than one node matched. |
* Fill one of the two: Input XML or Input XML file. With both empty, the step fails with Input xml cannot be null or empty.
Example
Input XML:
<bookstore>
<book><title lang="en">Harry Potter</title><price>29.99</price></book>
<book><title lang="en">Learning XML</title><price>39.95</price></book>
</bookstore>| XPath Expression | Is List | The resulting value | The resulting list of values |
|---|---|---|---|
/bookstore/book[1]/title | false | Harry Potter | empty |
//title | true | empty | ["Harry Potter", "Learning XML"] |
/bookstore/book[1] | false | <title lang="en">Harry Potter</title><price>29.99</price> | empty |
//title/@lang | true | empty | ["en", "en"] |
//author (no match) | false | empty | empty |
Good to know
- The value of a matched element is its inner content. For an element with children you get the child tags as text (see
/bookstore/book[1]above). - Select the element (
//title), not its text node (//title/text()): a text node comes back empty. - Only one of the two value outputs is filled. Check Is List, or map both outputs.
- A match on nothing does not fail the step; all outputs stay empty and Is List is
false. - The expression must select nodes. A function such as
count(//book)fails the step withInput XML or XPath was not valid., as does XML that is not well-formed. - Namespaces. For XML with a default namespace, such as
<Invoice xmlns="urn:test"><ID>INV-1</ID></Invoice>, the path/Invoice/IDfinds nothing. Uselocal-name()://*[local-name()='ID']returnsINV-1.
Related actions
- Update, XML Processor, XML Is Valid, XML To JSON
- Extract Objects, the same idea for JSON

