XML to JSON Transformer

Discover more about the XML to JSON Transformer connector and how to use it on the Digibee Integration Platform.

XML to JSON Transformer transforms an XML string into a JSON object.

Parameters

Configure the connector using the parameters below. Fields that support Double Braces expressions are marked in the Supports DB column.

Parameter
Description
Type
Supports DB
Default

Alias

Name (alias) for this connector’s output, allowing you to reference it later in the flow using Double Braces expressions

String

xml-to-json-1

XML Field Path

Path of the XML field to be transformed, using dotted notation. If the field is a matrix, all elements will be processed. You can specify multiple fields separated by commas.

String

body

Preserve Original

IIf enabled, the original fields are preserved in the transformation result. To differentiate the original fields from the transformed ones, an underscore (_) is added at the beginning of the original field names.

Boolean

True

With Namespace

If enabled, the XML namespaces are preserved in the transformation result.

Boolean

True

Remove XML Attributes

If enabled, the XML attributes are hidden in the transformation result.

Boolean

False

All Values As String

If enabled, all XML tag values are converted to the string type.

Boolean

False

Escape Special Characters

If enabled, automatically escapes reserved XML characters ( &, <, >) to prevent parsing errors during data transformation.

Boolean

False

Messages flow

Input

The connector doesn’t require a specific input message. You only need to configure the XML Field Path parameter with a reference to the field path that contains the XML to be transformed. This field must be present in the output of the step immediately before the XML to JSON Transformer execution.

Output

The output structure remains the same as the one received in the previous step. The fields specified in the XML Field Path parameter are transformed into their JSON object representation. If an error occurs, an error property is created at the same level as the original property.

When the Preserve Original parameter is enabled, each field defined in the XML Field Path parameter generates an additional property prefixed with an underscore (_), containing the original XML string.

The JSON dotted notation identifies the root element being processed by the pipeline and navigates through it according to the path defined in the XML Field Path parameter.

Example:

In an XML Field Path represented as a.b.c.d, the connector will:

  1. Look for the element a at the root level.

  2. Inside a it will find b.

  3. Then, inside b it will find c.

  4. Finally, it will access d, which is the element to be transformed.

The connector identifies each <d> element inside <c> → <b> → <a> and converts them into JSON.

If an array is found along the path (for example, if b contains multiple items), the algorithm processes each array element individually, creating a separate path for each one.

In other words, the algorithm replaces all occurrences of the path defined in the XML Field Path parameter throughout the message.

XML to JSON Transformer in action

For all the scenarios below, the following payload will be considered with the XML String field:

{
  "xmlField": "<?xml version=\"1.0\" ?><inf:ProductInformation xmlns:inf=\"urn:product:Info\" xmlns:stk=\"urn:product:Stock\"><inf:ProductName Code=\"C00001\">Computer</inf:ProductName><inf:Price Units=\"$\">2500</inf:Price><stk:Volume Units=\"Units\">200</stk:Volume></inf:ProductInformation>"
}

XML Transformation

Input

Parameters

  • XML Field Path: xmlField

  • Preserve Original: false

  • With Namespace: false

  • Remove XML Attributes: false

  • All Values As String: false

Output

{
  "xmlField": {
    "ProductInformation": {
      "ProductName": {
        "Code": "C00001",
        "content": "Computer"
      },
      "Price": {
        "Units": "$",
        "content": 2500
      },
      "Volume": {
        "Units": "Units",
        "content": 200
      },
      "xmlns:stk": "urn:product:Stock",
      "xmlns:inf": "urn:product:Info"
    }
  }
}

XML Transformation with the "Preserve Original" parameter enabled

Input

Parameters

  • XML Field Path: xmlField

  • Preserve Original: true

  • With Namespace: false

  • Remove XML Attributes: false

  • All Values As String: false

Output

{
  "xmlField": {
    "ProductInformation": {
      "ProductName": {
        "Code": "C00001",
        "content": "Computer"
      },
      "Price": {
        "Units": "$",
        "content": 2500
      },
      "Volume": {
        "Units": "Units",
        "content": 200
      },
      "xmlns:stk": "urn:product:Stock",
      "xmlns:inf": "urn:product:Info"
    }
  },
  "_xmlField": "<?xml version=\"1.0\" ?><inf:ProductInformation xmlns:inf=\"urn:product:Info\" xmlns:stk=\"urn:product:Stock\"><inf:ProductName Code=\"C00001\">Computer</inf:ProductName><inf:Price Units=\"$\">2500</inf:Price><stk:Volume Units=\"Units\">200</stk:Volume></inf:ProductInformation>"
}

XML Transformation with the "With Namespace" parameter enabled

Input

Parameters

  • XML Field Path: xmlField

  • Preserve Original: false

  • With Namespace: true

  • Remove XML Attributes: false

  • All Values As String: false

Output

{
  "xmlField": {
    "inf:ProductInformation": {
      "inf:Price": {
        "Units": "$",
        "content": 2500
      },
      "xmlns:stk": "urn:product:Stock",
      "xmlns:inf": "urn:product:Info",
      "inf:ProductName": {
        "Code": "C00001",
        "content": "Computer"
      },
      "stk:Volume": {
        "Units": "Units",
        "content": 200
      }
    }
  }
}

XML Transformation with the "Remove XML Attributes" parameter enabled

Input

Parameters

  • XML Field Path: xmlField

  • Preserve Original: false

  • With Namespace: false

  • Remove XML Attributes: true

  • All Values As String: false

Output

{
  "xmlField": {
    "ProductInformation": {
      "ProductName": "Computer",
      "Price": 2500,
      "Volume": 200
    }
  }
}

XML Transformation with the "All Values As String" parameter enabled

Input

Parameters

  • XML Field Path: xmlField

  • Preserve Original: false

  • With Namespace: false

  • Remove XML Attributes: false

  • All Values As String: true

Output

{
  "xmlField": {
    "ProductInformation": {
      "ProductName": "Computer",
      "Price": "2500",
      "Volume": "200"
    }
  }
}

XML Transformation with the with “Escape Special Characters” parameter enabled

Input

{
  "xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<sales_report>\n  <company>Solutions &amp; Co. Ltd.</company>\n  <generation_date>2025-10-13</generation_date>\n  \n  <product id=\"A101\">\n    <name>TurboX Graphics Card</name>\n    <stock>50</stock>\n    <rating>4.5</rating>\n    <comparison>Performance &gt; Price</comparison>\n  </product>\n  \n  <product id=\"B202\">\n    <name>Velox 9 Processor</name>\n    <stock>35</stock>\n    <rating>4.8</rating>\n    <comparison>Cost &lt; Benefit</comparison>\n  </product>\n  \n  <notes>\n    Review order #PO-789 &amp; #PO-790.\n    The sales goal is &gt; 100 units for the Velox 9 Processor.\n    The cost must be &lt; $500 per unit.\n  </notes>\n  \n</sales_report>"
}
  • XML Field Path: xmlField

  • Preserve Original: false

  • With Namespace: false

  • Remove XML Attributes: false

  • All Values As String: false

  • Escape Special Characters: true

{
  "xml": {
    "sales_report": {
      "notes": "    Review order #PO-789 & #PO-790.\n    The sales goal is > 100 units for the Velox 9 Processor.\n    The cost must be < $500 per unit.\n ",
      "product": [
        {
          "stock": 50,
          "comparison": "Performance > Price",
          "name": "TurboX Graphics Card",
          "id": "A101",
          "rating": 4.5,
          "content": [
            "   ",
            "   ",
            "   ",
            "   ",
            " "
          ]
        },
        {
          "stock": 35,
          "comparison": "Cost < Benefit",
          "name": "Velox 9 Processor",
          "id": "B202",
          "rating": 4.8,
          "content": [
            "   ",
            "   ",
            "   ",
            "   ",
            " "
          ]
        }
      ],
      "company": "Solutions & Co. Ltd.",
      "content": [
        " ",
        " ",
        "  \n ",
        "  \n ",
        "  \n ",
        "  "
      ],
      "generation_date": "2025-10-13"
    }
  }
}

Last updated

Was this helpful?