# XML batch processing

<figure><img src="/files/d0dfbcf2b9be70d632a6534b61cfcc5e10d4a45f" alt=""><figcaption></figcaption></figure>

### Purpose

The XML Batch element is designed to read and process very large XML files by breaking them into smaller, manageable parts called "batches." It uses a stream reader to avoid loading the entire file into memory, which is essential for handling massive XML datasets.

* This element acts as the starting point for a batch processing loop. The flow path connected after this element is executed once for each batch of records (nodes) read from the XML file until the entire file has been processed.

Use cases:

* Importing a large product feed from a supplier in XML format.
* Processing large, complex XML data exports from enterprise systems.
* Reading and synchronizing data from a huge XML file without hitting memory limits.

***

### Practical usage notes

* Batch processing loop: This element initiates a loop. For example, if you have an XML file with 5,000 `<item>`records and a batch size of 500, the subsequent flow path will be executed 10 times.
* Combination with "For Each": A common pattern is to connect this element with a `For Each`loop. The `XmlBatch`element fetches a batch of records (e.g., 500), and the `For Each`loop then iterates over each individual record to process it.
* Target tag is crucial: In manual mode, correctly identifying the target XML tag is the most important step. This tells the parser what defines a single "row" of data in your file.

***

### Configuration options

#### File and batch settings

| **Option**   | **Description**                                                                              | **Input format**    | **Example value**           |
| ------------ | -------------------------------------------------------------------------------------------- | ------------------- | --------------------------- |
| XML path     | The path to the `.xml`file in the platform storage that should be processed.                 | String (file path). | `/imports/product_feed.xml` |
| Batch size   | The number of main XML nodes (records) to read for each batch. (Required field).             | Integer.            | `500`                       |
| Archive file | If enabled, the source XML file will be moved to an archive directory after full processing. | Checkbox (Boolean). | `true`                      |

#### Structure configuration

| **Option**     | **Description**                                                                                                                     | **Input format**                        |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
| Type           | Defines how the element interprets the XML file: `Manual` (Define tags) or `Data structure` (Use a preconfigured structure).        | Selection (Dropdown).                   |
| Data structure | Choose a predefined `Data structure` to automatically parse the XML file. (Appears only when the type is set to `Data structure` ). | Selection of available data structures. |

#### Manual configuration settings (when type is `Manual`)

| **Option**      | **Description**                                                                                                                       | **Input format**     | **Example value** |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ----------------- |
| Encoding        | The character encoding of the XML file.                                                                                               | String.              | `UTF-8`           |
| Target XML tag  | The name of the repeating XML tag that represents a single record (e.g., `<product>`).                                                | String.              | `product`         |
| Force array for | A list of nested XML tag names that should always be treated as arrays, even if only one tag exists (for consistent data structures). | A list of tag names. | `image`           |

***

### Input/output expectations

* Input: The element requires at least the XML path.
* Output: The primary output is the variable entries.
  * This variable contains a JSON array of the records (parsed from the target XML tags) in the current batch.
  * The subsequent flow path is executed repeatedly, once for each batch, until the entire file has been processed.

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://connect.xentral.com/connect/connect-en/features/flows/flow-editor/components/files/xml-batch-processing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
