XML

XML is used to describe the transportation, structure, and storage of data.

It allows users to convert XML attachments and strings to and from JSON. This component has three actions allowing users to pass in either generic but well-formatted XML/JSON strings or XML attachments. It produces a generic string or attachment of the other file type. The output then can be mapped and used in other components.

Requirements and conversion behavior

Provided XML document (for XML to JSON) should be well-formed to be parsed correctly. You will get an error otherwise.

JSON inputs must be objects with precisely one field, as XML documents must be contained in a single root tag. JSON inputs can not have any field names which are not valid as XML tag names:

  • They must start with a letter or underscore.

  • They cannot start with the letters xml (regardless of capitalization).

  • They must only contain letters, digits, hyphens, underscores, and periods.

  • XML attributes on a tag can be read and set by setting an _attr sub-object in the JSON.

  • The inner-text of an XML element can also be controlled with # sub-object.

For example:

{
  "someTag": {
    "_attr": {
      "id": "my id"
    },
    "_": "my inner text"
  }
}

The code above is equivalent to:

<someTag id="my id">my inner text</someTag>

Environment variables

Max_file_size

Controls the maximum size of an attachment to be written in MB. Defaults to 10 MB where 1 MB = 1024 * 1024 bytes. This setting is optional.

Trigger

This component has no trigger functions. This means you can not select it as a first component during the integration flow design.

Actions

XML to JSON

Takes XML string and converts it to a generic JSON object.

Limitation

The value inside XML tags will be converting into a string only, for example:

<note>
  <date>2015-09-01</date>
  <hour>08:30</hour>
  <to>Tove</to>
  <from>Jani</from>
  <body>Don't forget me this weekend!</body>
</note>
XML string

The above sample will be converted into:

{
  "note": {
    "id": "322",
    "to": "Tove",
    "from": "Jani",
    "heading": "Reminder",
    "body": "Don't forget me this weekend!"
  }
}
Convert into JSON

XML attachment to JSON

Parses the JSON array of attachments passed into the component and converts any XML to generic JSON objects, producing one outbound message per matching attachment. The user can enter a pattern to filter files by name or leave this field empty for processing all incoming *.xml files.

XML attachment to JSON

JSON to XML

Provides an input where a user provides a JSONata expression that should evaluate to an object to convert to JSON. Conversion logic was covered in the above Requirements and conversion behavior section.

The following options are supported:

Upload XML as file to attachments

When selected, this setting will place the resulting XML directly into an attachment. The attachment information will be provided in the message’s attachments section, and attachmentUrl and attachmentSize will be populated. The attachment size will be described in bytes. When this box is not selected, the resulting XML will be provided in the xmlString field.

Exclude XML header/description

When checked, no XML header of the form <?xml version="1.0" encoding="UTF-8" standalone="no"?> will be prepended to the XML output.

Is the XML file standalone

When this option is selected, the XML header/description will have a Yes value for standalone. Otherwise, the value will be no. Has no effect when XML header/description is excluded.

The incoming message should have a single field input. When using integrator mode, this appears as the input JSON to convert. When building mappings in developer mode, one must set the input property.

For example:

{
  "input": {
             "someTag": {
               "_attr": {
                 "id": "my id"
               },
               "_": "my inner text"
             }
           }
}
JSON to XML

Known limitations

The maximum size of the incoming file for processing is 5 MB. If the size of the incoming file is more than 5 MB, action will throw an error:

Attachment *.xml is too large to be processed by the XML component.
File limit is: 5242880 byte, file given was: * byte

All actions involving attachments are not supported on local agents due to current platform limitations. When creating XML files with invalid XML tags, the name of the potentially invalid tag will not be reported.