XML Decoder Processor

The “XML Decoder Processor” is installed with the Dataristix Application. The processor accepts any input values and decodes the incoming XML document to extract tag values.

Add to Task

Add the “XML Decoder” to a task by dragging it from the “Build” panel onto the task’s “Task Builder” panel.

../../_images/processor-xmldecoder.png

Configuration

Select the “XML Decoder Processor” item in the “Task Builder” panel to view its properties.

You can change the following properties:

  • Name
    The title of the “XML Decoder Processor” as it appears within the task builder.
  • XPath to Tag Nodes
    The XPath to pre-select XML nodes from where tag values should be extracted (see examples below). If the XPath is left blank, then the entire XML document input is pre-selected.
  • Property Name / XPath pairs
    A list of property name and XPath pairs separated by comma, one pair per line. The property name determines the name of the output tag of the XML Decoder task node. The XPath determines how to extract a value for the property from the XML nodes pre-selected by “XPath to Tag Nodes” (see examples below).

Both “XPath to Tag Nodes” and each property’s XPath accept any standard XPath 1.0 expression - not a Dataristix-specific subset.

If “XPath to Tag Nodes” matches more than one XML node, then “Property Name / XPath pairs” must be left empty; the output is an array of strings, one per matched node (see Example 2 below). Combining a “XPath to Tag Nodes” that matches more than one node with a non-empty “Property Name / XPath pairs” list is invalid and produces a task error at runtime, with no output. To extract properties from each of several matched nodes, first decode the node array as shown in Example 2, then feed each element (for example via an Array Sequencer Processor) into a second XML Decoder configured with the property XPaths, as shown in Example 2’s continuation below.

Press the “Apply” button to commit your changes.

Example 1

The following example shows a task that receives a simple XML document containing a single value. The document is:

<values>
    <value>1234</value>
</values>

To extract the value, the XML Decoder is configured as follows:

../../_images/processor-xmldecoder-example2.png

The “XPath to Tag Nodes” is set to values. This will select the content of the “values” XML node for property extraction. The property name and XPath pairs are set to value,value which means that the output tag name of the XML Decoder should be “value” (any other name will work as well) and the value for that property should be extracted via XPath “value” applied to the preselected content of the “values” XML node.

The XML Decoder extracts the value from the document and makes it available for further processing.

../../_images/processor-xmldecoder-example1.png

Example 2

In this example, we want to extract multiple values from an XML document. The document is:

<values>
    <value>1</value>
    <value>2</value>
    <value>3</value>
</values>

To extract the (multiple) values, the XML Decoder is configured as follows:

../../_images/processor-xmldecoder-example4.png

The “XPath to Tag Nodes” is set to values/value. This will select an array of “value” XML nodes. The property name and XPath pairs are left blank, which means that the output is an array of strings containing each “value” XML node.

../../_images/processor-xmldecoder-example3.png

The image above shows the input XML document (1) that is sent to the XML Decoder (2). The output terminator (3) shows the output of the XML Decoder, consisting of an array of strings “<value>1</value>”, “<value>2</value>” and “<value>3</value>” which can then be used for further processing. In the example, the string array is sent to an Array Sequencer Processor (4) from where each individual element is sent to the final output stage (5).

Adding additional XML Decoders here would allow extracting each individual value. To extract the value from an XML document in the form

<value>1</value>

use an empty “XPath to Tag Nodes” and a property name and XPath pair value,. to extract the current node content.