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

> Reads cXML documents and turns them into structured data you can map and transform.

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 cXML documents (the XML format used for purchase orders, invoices, and other procurement messages) and turns them into structured data you can map and transform. cXML files normally begin with a `<!DOCTYPE ...>` declaration that points at an external definition; this parser removes that declaration before reading the document, so the data loads even when that external definition is not reachable. XML attributes become keys prefixed with `@`, and nested elements become nested objects.

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

## Fields

<FormField property="xmlTypeCastAttributes" label="Automatically convert value's types">
  Leave this on (the default) to have attribute values that look like numbers read as actual numbers, so `payloadID="123"` comes back as `123` rather than the text `"123"`. Turn it off to keep every attribute exactly as written in the cXML, which matters for codes that must not be reinterpreted as numbers. Attribute values with a leading zero, such as `"042000123"`, are never converted, and the text inside elements is always kept as written.
</FormField>

<FormField property="encodeInput" label="Input data is not UTF-8 encoded">
  An on/off toggle, off by default, which assumes the incoming cXML is already UTF-8. Turn it on only when the file uses a different character set so that accented and other special characters come through correctly. When on, two extra options appear so you can describe the original character set.
</FormField>

<FormField property="encodingFrom" label="Input encoding" required>
  Shown only when "Input data is not UTF-8 encoded" is on, and required there. The character set the file is actually saved in, so it can be converted to UTF-8 before parsing. Choose from UTF-16, ISO-8859-1, or Windows-1252.
</FormField>

<FormField property="modifier" label="On unconvertible characters">
  Shown only when conversion is on. Controls what happens to a character that has no UTF-8 equivalent: NONE stops with an error, IGNORE drops the character, and TRANSLIT replaces it with the closest similar character.
</FormField>

## Sample data

| Field | Value |
| - | - |
| Automatically convert value's types | On (default) |

Input (a cXML purchase order):

```xml theme={null}
<cXML payloadID="123" timestamp="2024-01-01T10:00:00">
  <Header>
    <From>
      <Credential domain="NetworkID"><Identity>SupplierA</Identity></Credential>
    </From>
  </Header>
  <Request>
    <OrderRequest>
      <OrderRequestHeader orderID="PO-1024" type="new"/>
    </OrderRequest>
  </Request>
</cXML>
```

Output:

```json theme={null}
{
    "@payloadID": 123,
    "@timestamp": "2024-01-01T10:00:00",
    "Header": {
        "From": {
            "Credential": {
                "@domain": "NetworkID",
                "Identity": "SupplierA"
            }
        }
    },
    "Request": {
        "OrderRequest": {
            "OrderRequestHeader": {
                "@orderID": "PO-1024",
                "@type": "new",
                "#": ""
            }
        }
    }
}
```

Because type conversion is on, `payloadID="123"` comes back as the number `123`. With the option off it stays the text `"123"`, and all other values are unchanged.

```json Configuration theme={null}
{
  "prototype": "cxml",
  "parameters": {}
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.