> For the complete documentation index, see [llms.txt](https://docs.locoia.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.locoia.com/connectors/helpers/xml-helper.md).

# XML Helper

<figure><img src="https://291121471-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McrRFZHYH27bqKzOVDd%2Fuploads%2FTJ5mZcnDGvyNrAX6LQog%2Fimage.png?alt=media&amp;token=adc7ff3e-74fb-45d5-8b86-d1f1d0864e67" alt="" width="155"><figcaption></figcaption></figure>

## Overview

The **XML Helper** converts XML to dictionaries or vice versa. It connects XML-based APIs to the integration platform.

## Actions

### 1. Convert dictionary to XML

To convert a dictionary to XML, e.g. for use in the REST helper, use the **Convert dictionary to XML** action. Just reference the object directly, without `{{ }}`

<figure><img src="https://291121471-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McrRFZHYH27bqKzOVDd%2Fuploads%2FXx20XqG8t9bpltHKjFlY%2Fimage.png?alt=media&amp;token=058c4439-4592-4678-bbac-ac517ffeb70d" alt="" width="563"><figcaption></figcaption></figure>

#### XML Attributes

If you want to include [XML attributes](https://www.w3schools.com/xml/xml_attributes.asp) in the outputted XML, e.g.:

```xml
<?xml version="1.0" encoding="utf-8"?>
<Example id="somevalue" type="text">
  <Content>Some Text</Content>
</Example>
```

You need to include the attributes in the dictionary with an `@` prefix, e.g.:

```json
{
  "Example": {
    "@id": "somevalue",
    "@type": "text",
    "Content": "Some Text",
  }
}
```

### 2. Convert XML to dictionary

To retrieve an XML file or endpoint, just include the internal Locoia reference or the external URL, like in the below screenshot the VAT-ID check of the EU commission.&#x20;

{% hint style="info" %}
Since XML responses are sometimes "not so clean", please reference data as per the below. This is the better approach compared to JSONPath-notation.

`myOldErp["users"]["first_name"]`
{% endhint %}

<figure><img src="https://291121471-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McrRFZHYH27bqKzOVDd%2Fuploads%2FYM78EDr7L8nDFVpfrKrt%2Fimage.png?alt=media&amp;token=a0993d55-f0d7-435b-b916-357dde51edaa" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="info" %}
If an XML only contains one entry of an object, it will be output as a dictionary in JSON.\
However, if it has multiple entries of an object it will be output as a list of dictionaries. \
To check the output type dynamically in a flow you use the Jinja `mapping` test, e.g.:

```django
{% if dic1 is mapping %}
  "Dict"
{% else %}
  "List"
{% endif %}
```

{% endhint %}

### 3. Drop Namespaces

Sometimes you may want to drop the namespaces of an existing XML. This can be done with the **Drop Namespaces** action.

<figure><img src="https://291121471-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McrRFZHYH27bqKzOVDd%2Fuploads%2FDYZ6QGQF9DuvUsgt5yL4%2Fimage.png?alt=media&amp;token=57b9b3ab-fd30-4cb6-898e-68a3f280cbf3" alt="" width="563"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.locoia.com/connectors/helpers/xml-helper.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
