> For the complete documentation index, see [llms.txt](https://docs.uibakery.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uibakery.io/how-tos/file-management/parsing-and-sending-xml.md).

# Parsing and sending XML

In this article, we'll explore ways of parsing and sending XML in UI Bakery. Review the sections below to learn how to do that.

## Parsing an XML string to a JS Object

1. Navigate to the **Custom code** tab and specify the following script:

```javascript
<script src="https://cdnjs.cloudflare.com/ajax/libs/fast-xml-parser/4.3.2/fxparser.min.js" ></script>
```

2. Create an **HTTP Request** action selecting the *GET* method and specifying the necessary *URL*.
3. Next, turn on the **Transform result** toggle to open the mapper field and specify the following code:

```javascript
const xmlContent = atob({{data.base64}});
  
const parser = new XMLParser();
return parser.parse(xmlContent);
```

{% hint style="info" %}
Instead of the *Transform result*, you can add a **JavaScript Code** action as the second step to the HTTP Request action.
{% endhint %}

4. Click **Execute action**.

{% @arcade/embed flowId="qOai5eaBTlOBuvOzd5D1" url="<https://app.arcade.software/share/qOai5eaBTlOBuvOzd5D1>" %}

## Sending an XML string from UI Bakery

1. Navigate to the **Custom code** tab and specify the following scripts:

```javascript
<script src="https://cdnjs.cloudflare.com/ajax/libs/fast-xml-parser/4.3.2/fxparser.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jstoxml@3.2.10/dist/jstoxml.min.js"></script>
```

2. Now, create a new action consisting of *two steps*:
   1. For the **first** step, add a **JavaScript Code** action that will generate an XML from JSON:<br>

      ```javascript
      const jsonData = await {{actions.requestData.trigger()}};
      return jstoxml.toXML(jsonData);

      //where requestData is an action that returns data to be sent as XML (for example, HTTP Request or Load Table action)
      ```
   2. For the **second** step, add an **HTTP Request** action that will send the request:\
      \
      — Select *POST* method and specify the *URL*\
      — For **Headers** - specify `Content-Type` `application/xml` \
      — For **Body** - `{{data}}`, as the result of the first step
3. Click **Execute action**.

{% @arcade/embed flowId="lfYWhJMpsOns5iOZX3Zx" url="<https://app.arcade.software/share/lfYWhJMpsOns5iOZX3Zx>" %}


---

# 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 dynamically by asking a question.

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

```
GET https://docs.uibakery.io/how-tos/file-management/parsing-and-sending-xml.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
