# xml

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: xml
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: connect/components/processors/xml
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: connect/components/processors/xml.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/develop/pages/connect/components/processors/xml.adoc
page-git-created-date: "2024-09-09"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/xml.md -->

**Available in:** Cloud, [Self-Managed](https://docs.redpanda.com/connect/components/processors/xml/%20%22View%20the%20Self-Managed%20version%20of%20this%20component%22)

Parses messages as an XML document, performs a mutation on the data, and then overwrites the previous contents with the new value.

```yml
# Config fields, showing default values
label: ""
xml:
  operator: ""
  cast: false
```

## [](#operators)Operators

### [](#to_json)`to_json`

Converts an XML document into a JSON structure, where elements appear as keys of an object according to the following rules:

-   If an element contains attributes they are parsed by prefixing a hyphen, `-`, to the attribute label.

-   If the element is a simple element and has attributes, the element value is given the key `#text`.

-   XML comments, directives, and process instructions are ignored.

-   When elements are repeated the resulting JSON value is an array.

-   XML namespaces are stripped from element and attribute names, and namespace declarations (`xmlns`) are omitted.


For example, given the following XML:

```xml
<root>
  <title>This is a title</title>
  <description tone="boring">This is a description</description>
  <elements id="1">foo1</elements>
  <elements id="2">foo2</elements>
  <elements>foo3</elements>
</root>
```

The resulting JSON structure would look like this:

```json
{
  "root":{
    "title":"This is a title",
    "description":{
      "#text":"This is a description",
      "-tone":"boring"
    },
    "elements":[
      {"#text":"foo1","-id":"1"},
      {"#text":"foo2","-id":"2"},
      "foo3"
    ]
  }
}
```

With cast set to true, the resulting JSON structure would look like this:

```json
{
  "root":{
    "title":"This is a title",
    "description":{
      "#text":"This is a description",
      "-tone":"boring"
    },
    "elements":[
      {"#text":"foo1","-id":1},
      {"#text":"foo2","-id":2},
      "foo3"
    ]
  }
}
```

## [](#fields)Fields

### [](#cast)`cast`

Whether to try to cast values that are numbers and booleans to the right type. Default: all values are strings.

**Type**: `bool`

**Default**: `false`

### [](#operator)`operator`

An XML [operation](#operators) to apply to messages.

**Type**: `string`

**Default**: `""`

**Options**: `to_json`