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

# XML

> Read a stream as XML data.

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 an incoming stream of XML, such as a downloaded file or an API response, and turns it into items your integration can work with. Use this when the data you receive is XML. You can read the whole document at once, which is simplest for normal-sized files, or read it incrementally, which lets you process very large files element by element without loading everything into memory.

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

## Fields

<FormField property="readMethod" label="Read method">
  Choose how the file is read. **Whole file (for smaller files)** loads the entire document and then processes it, and lets you set a Pattern to items. **Incremental (for large files)** streams through the document element by element so a very large file never has to fit in memory, and lets you set a Path to incrementally read over instead. Defaults to Whole file.
</FormField>

<FormField property="pattern" label="Pattern to items">
  Shown when the read method is Whole file. A dot-notated path to the list inside the parsed XML that holds the items you want to process, so each item becomes a separate entity. For example, use `products.product` to read each `<product>` from `<products><product>...</product></products>`. Leave it empty to treat the whole document as a single item. Do not add `*`; the system steps through the list for you.
</FormField>

<FormField property="path" label="Path to incrementally read over">
  Shown when the read method is Incremental. The element names that lead to the items you want to stream over, one per row. For example, for `<products><product/></products>` enter `products`, then `product`.
</FormField>

<FormField property="xmlTypeCastAttributes" label="Automatically convert value's types">
  When on (the default), values that look like numbers are turned into numbers, so `"-034"` becomes `-34`. Turn it off to keep every value exactly as written in the XML.
</FormField>

<FormField property="encodeInput" label="Input stream is not UTF-8 encoded">
  Turn this on when the incoming data uses a character encoding other than UTF-8, so accented and special characters come through correctly. It reveals two more settings: the encoding the data is currently in, and how to handle characters that cannot be converted.
</FormField>

<FormField property="encodingFrom" label="Input encoding">
  Shown when the input is not UTF-8. The character encoding the incoming data is currently in. Choose from UTF-16, ISO-8859-1, or Windows-1252.
</FormField>

<FormField property="modifier" label="On unconvertible characters">
  Shown when the input is not UTF-8. What to do with characters that have no UTF-8 equivalent: NONE keeps them as-is, IGNORE drops them, and TRANSLIT replaces them with the closest available character.
</FormField>

## Sample data

This format reads an incoming stream, so it is selected on a step that fetches a file or a response (for example reading a file from a folder) rather than run on data you already have. The example below shows the XML it reads and the items it produces with the settings listed.

| Field | Value |
| - | - |
| Read method | Whole file |
| Pattern to items | `products.product` |
| Automatically convert value's types | On |

Input (the XML in the stream):

```xml theme={null}
<products>
  <product><sku>A1</sku><price>34</price></product>
  <product><sku>B2</sku><price>19</price></product>
</products>
```

Output (one item per matched element, with numeric values converted):

```json theme={null}
{ "sku": "A1", "price": 34 }
{ "sku": "B2", "price": 19 }
```

```json Configuration theme={null}
{
  "prototype": "xml",
  "parameters": {
    "readMethod": "wholeFile",
    "pattern": "products.product",
    "xmlTypeCastAttributes": true
  }
}
```


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