> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Format to XML

> Converts a data object or array into an XML formatted string.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Turns a piece of structured data, such as an object or a list, into a single XML text string. Use this when a system you send data to expects an XML document rather than separate fields. Each field becomes an element, and the whole message is wrapped in one outer element whose name you can choose.

This documentation describes: [Schema](/schemas/mapper/serialize-xml)

## Fields

<FormField property="rootNodeName" label="Root element name">
  The name of the outer element that wraps the whole message. Defaults to `response`. Set this to whatever the receiving system expects, for example `product` or `Invoice`.
</FormField>

<FormField property="noCdataWrapping" label="Disable cData wrapping">
  An on/off toggle. When off (the default), any value that contains XML markup is wrapped in a `<![CDATA[ ... ]]>` block so the markup is treated as plain text instead of being parsed. Turn this on to leave such values unwrapped.
</FormField>

## Sample data

This example formats one object and names the outer element `product`.

| Field             | Value     |
| ----------------- | --------- |
| Root element name | `product` |

Input:

```json theme={null}
{
    "product": {
        "sku": "SCARF-01",
        "name": "Wool scarf",
        "price": 24.95
    }
}
```

Output:

```json theme={null}
{
    "product": "<?xml version=\"1.0\"?>\n<product><sku>SCARF-01</sku><name>Wool scarf</name><price>24.95</price></product>\n"
}
```

```json Configuration theme={null}
{
  "prototype": "serialize-xml",
  "parameters": {
    "rootNodeName": "product"
  }
}
```
