> ## 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.

# Parse from XML

> Converts XML data into JSON.

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>;
};

Reads a piece of XML text and turns it into structured data you can map field by field. Use this when a value arrives as an XML document, such as an order or product feed pulled from an API response, a file, or a single message field, and you want to work with its elements and attributes as ordinary fields instead of one long string. Each XML element becomes a key, nested elements become nested data, and attributes appear under keys prefixed with `@`.

If the incoming text is in a character set other than UTF-8, you can turn on the encoding option to have it converted first.

This documentation describes: [Schema](/schemas/deserializer/xml)

## Fields

<FormField property="xmlTypeCastAttributes" label="Automatically convert value's types">
  Leave this on (the default) to have number-like values read as actual numbers, so `"49.95"` comes back as `49.95` rather than text. Turn it off to keep every value exactly as written in the XML. This is handy when codes such as `"-034"` would otherwise lose their leading zeros or signs.
</FormField>

<FormField property="encodeInput" label="Input data is not UTF-8 encoded">
  Turn this on when the incoming text is in a character set other than UTF-8, so accented and special characters come through correctly. It is off by default. Turning it on reveals the encoding and conversion options below.
</FormField>

<FormField property="encodingFrom" label="Encoding">
  The character set the incoming text is currently in. Choose from UTF-16, ISO-8859-1, or Windows-1252. Only shown when the encoding option above is on.
</FormField>

<FormField property="modifier" label="Conversion behaviour">
  How to handle characters that cannot be converted to UTF-8: leave it as NONE to fail on an unconvertible character, IGNORE to drop it, or TRANSLIT to replace it with the closest available character. Only shown when the encoding option is on.
</FormField>

## Sample data

| Field                               | Value |
| ----------------------------------- | ----- |
| Automatically convert value's types | On    |

Input:

```json theme={null}
{
    "payload": "<order><id>1001</id><customer>Acme</customer><total>49.95</total></order>"
}
```

Output:

```json theme={null}
{
    "payload": {
        "id": 1001,
        "customer": "Acme",
        "total": 49.95
    }
}
```

Each element becomes a field, and because type conversion is on, `1001` and `49.95` come back as numbers rather than text.

```json Configuration theme={null}
{
  "prototype": "xml",
  "parameters": {
    "xmlTypeCastAttributes": true
  }
}
```
