Define Actions Using XML Collections and JSON Arrays

One-Step™ Actions include options for iterating through XML Collections and JSON Arrays and extracting portions of repeating data. Refer to these tasks and code samples when defining Actions using variables of type XML Collection or JSON Array.

See also Webhook Modifier Examples.

XPATH version 1.0 is supported; XPATH version 2.0 is not supported.

Task XML Example JSON Example Notes

Create a variable that contains XML or JSON code. This is the XML or JSON variable.

<Remarks> <Remark> <Sequence>1</Sequence> <QualifierId>RAIL</QualifierId> <Text>CHICAGO</Text> </Remark> <Remark> <Sequence>2</Sequence> <QualifierId>RAIL</QualifierId> <Text>CHICAGO</Text> </Remark> <Remark> <Sequence>3</Sequence> <QualifierId>DEST</QualifierId> <Text>CALL 24 HRS B4.</Text> </Remark>
{ "node": [ { "key1": "Value1"}, { "key2": "Value2"}, { "key3": "Value3"} ] }

Usually, this is accomplished by calling a Web Service and saving the result as a variable.

Create another variable to hold the XML Collection or JSON Array. This is the collection variable. Give the variable the correct data type.

XML Collection

JSON Array

An XML Collection is a block of XML code that contains a common tag. In this example, the common tag is the Remark tag.

A JSON Array is a block of JSON code contained in square brackets that is the value of a JSON property. It typically contains a comma-delimited list of elements that are strings, numbers, objects, arrays, booleans or null. In this example, the JSON property containing the array is "node" and the array members are objects with key-value pairs.

Set the content of the collection variable as the XML or JSON variable. Use the applicable modifier to select the XML Collection or JSON Array element.

XPath = "//Remark"

<XPathSearchResult> <Remark> <Sequence>1</Sequence> <QualifierId>RAIL</QualifierId> <Text>CHICAGO</Text> </Remark> <Remark> <Sequence>2</Sequence> <QualifierId>RAIL</QualifierId> <Text>CHICAGO</Text> </Remark> <Remark> <Sequence>3</Sequence> <QualifierId>DEST</QualifierId> <Text>CALL 24 HRS B4.</Text> </Remark>

Find Array ("node")

[ { "key1": "Value1"}, { "key2": "Value2"}, { "key3": "Value3"}

In this example, the XPath modifer selects a collection of Remark elements in the XML Collection.

The Find Array ("node") modifier selects the JSON Array that is associated with the property "node." For more complex JSON objects, consider using JSONPath expressions.

Remember: XML Collections and JSON Arrays are 0-indexed. If you add modifiers to extract specific items from collections, use Index(0) to specify the first item.

Add a Step Through Collection Action to the One-Step Editor and specify the variable name, example: Item.


{ "key1": "Value1"}