XML

Converts the event into an XML file. Once formatted, Output Pipeline stages can be used to write the file with a file-based connector such as File or Amazon S3.

Upon format the stage sets event.metadata.fileFormat to xml.

Output Type

This controls the output format of the XML formatted value.

  • String: The output event.value is a string that contains XML
  • FIle: The output event.value is a base64 encoded string. This is optimal for use with connections that support files.

Object and Array Formatting

The XML Format stage handles different data structures in the event.value as follows:

Single Object

When event.value contains a single object, it is converted to XML format with the object’s properties becoming XML elements. The object properties are wrapped with <value></value> unless the object contains a single key.

Object

Input JSON:

{
  "id": 1,
  "name": "Item A"
}

Output XML:

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<value>
    <id>1</id>
    <name>Item A</name>
</value>

Object with single key

Input JSON:

{
  "customKey": {
     "id": 1,
     "name": "Item A"
  }
}

Output XML:

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<customKey>
  <id>1</id>
  <name>Item A</name>
</customKey>

Array of Objects

When event.value is an array, each element is wrapped in a <value> tag.

Input JSON:

[
  {
    "id": 1,
    "name": "Item A"
  },
  {
    "id": 2,
    "name": "Item B"
  }
]

Output XML:

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<value>
  <value>
    <id>1</id>
      <name>Item A</name>
  </value>
  <value>
    <id>2</id>
    <name>Item B</name>
  </value>
</value>

Nested Arrays

Nested arrays are expanded and flattened, with each dimension wrapped in <value> tags to maintain the hierarchy. Nested arrays must be rectangular (all inner arrays at the same level must have the same length).

Input JSON:

[
  [
    {
      "id": 1,
      "name": "Item A"
    },
    {
      "id": 2,
      "name": "Item B"
    }
  ],
  [
    {
      "id": 3,
      "name": "Item C"
    },
    {
      "id": 4,
      "name": "Item D"
    }
  ]
]

Output XML:

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<value>
    <value>
        <value>
            <id>1</id>
            <name>Item A</name>
        </value>
        <value>
            <id>2</id>
            <name>Item B</name>
        </value>
    </value>
    <value>
        <value>
            <id>3</id>
            <name>Item C</name>
        </value>
        <value>
            <id>4</id>
            <name>Item D</name>
        </value>
    </value>
</value>