---
title: XML
slug: xml
image: https://make-cxp-documentation.ams3.cdn.digitaloceanspaces.com/apps-center-icons/PREVIEW_DEFAULT.png
docTags: 
createdAt: 2025-02-03T13:28:13.883Z
---

|   | With the XML app in Make, you can manage, parse, and bundle XML formatted text. |
| - | ------------------------------------------------------------------------------- |

:::hint{type="info"}
You do not need to establish a connection to use the XML app.
:::

# XML modules

You can use the following types of modules to build your scenarios.&#x20;

## Searches

### Perform XPath Query

| **Field**       | **Description**                                                                         |
| --------------- | --------------------------------------------------------------------------------------- |
| **XML**         | Enter the source XML document.                                                          |
| **XPath Query** | Enter the query in the [XPath](https://www.w3schools.com/xml/xpath_intro.asp) language. |

## Transformers

### Create XML

Converts a bundle to an XML formatted text.

| **Field**          | **Description**                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Data structure** | Describes the structure of the resulting XML.<br />If you have a sample of the XML you would like to parse, you can use it to generate the data structure:<br />1) Click **Add**.
2) Click **Generate**.
3) Copy and paste the XML sample into the **Sample data** field.
4) Click **Save**.
5) Verify that the data structure has been successfully generated.
6) Click **Save** to save the data structure. |

:::::ExpandableHeading
**Example - Create XML**

A typical use case is to transform data from a Google spreadsheet into XML.&#x20;

::::WorkflowBlock
:::WorkflowBlockItem
Place the **Google Sheets > Select rows** module in your scenario to fetch the data. Setup the module to retrieve rows from your Google spreadsheet and set the Maximum number of returned rows to a small number, but larger than one for testing purposes (e.g. three). Run the **Google Sheets** module (right-click it and choose "Run this module only") and verify the output of the module.
:::

:::WorkflowBlockItem
Connect the **Array Aggregator** module after the Google Sheets module. In the module's setup choose the **Google Sheets** module in the Source node field. Leave the other fields as they are for the moment.
:::

:::WorkflowBlockItem
Connect the **XML > Create XML** module after the **Array Aggregato**r module. The module's setup requires a data structure that describes the structure of the XML output. Click on **Add** to open the data structure setup. The easiest way to create this Data structure is to generate it automatically from an XML sample. Click on **Generate** and paste your XML sample to the Sample data field:

![Create XML step 3](https://api.archbee.com/api/optimize/yAufeXqD1oGWOPBNi5MAm-Sv04BGAr3hnI_DC6GkC_b-20250304-150928.png)
:::

:::WorkflowBlockItem
Click **Save**. The specification field in the data structure setup should now contain the generated structure.
:::

:::WorkflowBlockItem
Change the name of your Data structure to something more specific (e.g. "My XML data structure") and click **Save**. A field corresponding to the root XML element should appear as a mappable field in the XML module's setup.
:::

:::WorkflowBlockItem
Click **Map** next to the field and map the `Array[]` item output from the **Array aggregator** module.
:::

:::WorkflowBlockItem
Click **OK** to close the XML module's setup.
:::

:::WorkflowBlockItem
Open the setup of the **Array Aggregator** module. Change the **target structure** from **Custom** to an **XML** module's field corresponding to the parent XML element. Map items output from the Google Sheets module to appropriate fields.

![Create XML step 8](https://api.archbee.com/api/optimize/yAufeXqD1oGWOPBNi5MAm-jEmSZqGtMwqHpX9t9UJ62-20250304-151235.png)
:::

:::WorkflowBlockItem
Click **OK** to close the **Array Aggregator** module's setup.
:::

:::WorkflowBlockItem
Run the scenario. The **XML** module should output the correct XML file. Open the setup of the **Google Sheets** module and increase the **Maximum number of returned rows** number to be larger than the number of rows in your spreadsheet to process all the data. The resulting XML can be then saved to Dropbox, sent as an attachment via email, uploaded via FTP to a server, etc.
:::
::::
:::::

:::ExpandableHeading
**Example - Add XML attributes**

If you want to add attributes to a complex node (a node, that will contain other nodes), you have to add a collection with the name `_attributes` for this node in your custom data structure, and this collection will be mapped to node attributes

If you want to add attributes to a text node (example: `<node attr="1">abc</node>`), you have to add a collection `_attributes` for attributes and a text property `_value` for the node value for this node in your custom data structure.

```text
{
    "name": "node",
    "type": "collection",
    "spec": [
        {
            "name": "_attributes",
            "type": "collection"
            "spec": [
                 {
                     "name": "attr1",
                     "type": "text"
                 }
            ]
        },
        {
            "name": "_value",
            "type": "text"
        }
    ]
}
```
:::

### Parse XML

Parses an XML formatted text and outputs a single bundle containing all the information extracted from the XML.

| **Field**          | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Data structure** | Select or add a date structure. <br />Describes the structure of the XML to make the output of the module available in the mapping panel for the modules that follow.<br />If you have a sample of the XML you would like to parse, you can use it to generate the data structure:<br />1) Click **Add**.
2) Click **Generate**.
3) Copy and paste the XML sample into the **Sample data** field.
4) Click **Save**.
5) Verify that the data structure has been successfully generated.
6) Click **Save** to save the data structure.<br />You can skip steps 2-5 to supply an empty data structure. This way the output of the module will not be available in the mapping panel until the module has been executed at least once to process an XML input. |
| **XML**            | Enter the XML to parse.<br />If you use a formula, make sure its result value type is (or can be automatically changed to) Text type. If the result value type is Buffer (binary data) then use `toString()` function to convert it to the Text type.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

:::::ExpandableHeading
**Example - Parse XML**

A typical use case is to download an XML file from a URL and parse its content. Here is a step by step guide how to achieve this:

::::WorkflowBlock
:::WorkflowBlockItem
Create a new scenario.
:::

:::WorkflowBlockItem
Add an **HTTP > Get a file** module.
:::

:::WorkflowBlockItem
Configure the module. Add the URL of the XML file.

![Configure the module](https://api.archbee.com/api/optimize/yAufeXqD1oGWOPBNi5MAm-dOsce38dAy3ar5pgh9O2u-20250304-145453.png)
:::

:::WorkflowBlockItem
Click **OK**.
:::

:::WorkflowBlockItem
Add the **XML > Parse XML** module, connect it after the **HTTP > Get a file** module and configure it.

**Data structure** field:

1. Click **Add**.
2. Click **Generate**
3. In your web browser, open a new tab/window.
4. Enter the URL you used in the third step in the address bar and fetch the XML file.
5. Select all the XML text and copy it into the clipboard.
6. Close the tab/window and get back to your scenario.
7. Paste the copied XML text into the **Sample data** field.
8. Click **Save**.
9. Verify that the data structure has been successfully generated.
10. Click **Save** to save the Data structure.

You can skip these steps to supply an empty data structure. This way the output of the module will not be available in the mapping panel until the module has been executed at least once to process an XML input.

**XML** field:

Map the `Data` item from the output of the **HTTP > Get a file** into this field. Use the `toString()` function to convert its value from Buffer (binary data) type to Text type.

You may copy and paste the formula's code into the field: `{{toString(1.data)}}`
:::
::::
:::::

:::ExpandableHeading
**Example - Parse XML attributes**

By default, the&#x20;**&#xA0;XML > Parse XML** module will put attributes in a special collection `_attributes` as a child of the node that has these attributes. If the node is a text node and it has attributes, then two special properties will be added: `_attributes` for attributes and `_value` for the text content of the node.

```text
<root attr="1">
    <node attr="ABC">Hello, World</node>
</root>
```

::Image[]{src="https://api.archbee.com/api/optimize/oAyFj2GHlBeBVWF5OAir2/pYda0yJeYxpar59klKt6X_uuid-5b23e5fc-2f1c-1612-df05-d4674639dee5.png" size="40" width="229" height="215" position="flex-start" alt="Parse XML attributes output" showCaption="false"}
:::

