> For the complete documentation index, see [llms.txt](https://community-test.logicnets.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://community-test.logicnets.com/release-9/platform-documentation/process-node-parts/xml-converter.md).

# XML Converter

## Description

This part allows you to convert XML to LUA or LUA to XML. Within the context of a LogicNets-based application data is stored in a LUA format, and there are times when the system receives external C. Sometimes external data is received in other formats like XML. This part can convert LUA to XML and XML to LUA.

XML language components and LUA language components (similar to JSON) do not match completely. XML has elements, element attributes, and element values; for example, *element-value*. In XML, elements can be nested and multiple elements with the same element name can exist on the same level. In LUA, however, data objects have names and values and can be nested, but multiple data objects with the same name on the same level is not possible. LUA supports arrays instead.

When the system finds a single element in XML it can convert it to a single value in LUA or to a collection with one entry. There is no LUA language construction for XML attributes. To support two-way conversion (XML to LUA and back to XML again) the outputted LUA structure contains additional levels to capture all information.

@ =

\#text =

\#index =

| XML                               | LUA                                                                                                                                                          |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| text e                            | <p>e = {<br>{ \["@name"] = "value", \["#text"] = "text e", \["#index"] = 1 }<br>}</p>                                                                        |
| <p><br>text a<br>text b<br></p>   | <p>e = {<br>{<br>\["#index"] = 1,<br>a = { { \["#text"] = "text a", \["#index"] = 1 } },<br>b = { { \["#text"] = "text b", \["#index"] = 2 } }<br>}<br>}</p> |
| <p><br>text a1<br>text a2<br></p> | <p>e = {<br>{<br>\["#index"] = 1,<br>a = {<br>{ \["#text"] = "text a1", \["#index"] = 1 },<br>{ \["#text"] = "text a2", \["#index"] = 2 }<br>}<br>}<br>}</p> |

There are also situations in which the XML does not contain any attributes or when the system can ignore the attributes. For these cases, the part also supports simplification mode. In this mode, the system ignores all XML attributes, stores the element value as a single value (no collection) if no elements with the same name occur on the same level, and does not store the position of elements in the XML in LUA.

| XML                               | LUA                                                |
| --------------------------------- | -------------------------------------------------- |
| text e                            | e = “text e”                                       |
| <p><br>text a<br>text b<br></p>   | <p>e = {<br>a = “text a”,<br>b = “text b”<br>}</p> |
| <p><br>text a1<br>text a2<br></p> | <p>e = {<br>a = { “text a1”, “text a2” }<br>}</p>  |

Simplified LUA structures cannot be converted back to XML.

## Editor Fields

Configure this part using the following fields:

| Tab   | Field Name                 | Description/Use                                                                                                                                | Type     | Mandatory/Optional |
| ----- | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------ |
| Basic | Mode                       | This is the mode for the conversion: XML to LUA \| LUA to XML                                                                                  | Dropdown | Mandatory          |
| Basic | Input text                 | This is the (XML to LUA) XML input.                                                                                                            | Text     | Mandatory          |
| Basic | Input Object               | This is the (LUA to XML) LUA input object.                                                                                                     | Object   | Mandatory          |
| Basic | Output Object              | This is the path where the system stores the result.                                                                                           | Object   | Mandatory          |
| Basic | Error Object               | This is the path where the system stores the conversion errors.                                                                                | Object   | Optional           |
| Basic | Lower case element names   | For XML to LUA, if you set this to *Yes* the system makes lower case all element names.                                                        | Y\|N     | Optional           |
| Basic | Lower case attribute names | For XML to LUA, if you set this to *Yes* the system makes all XML attribute names lower case.                                                  | Y\|N     | Optional           |
| Basic | Simplify                   | For XML to LUA, if you set this to Yes the system outputs a simplified LUA structure.                                                          | Y\|N     | Optional           |
| Basic | Element label attribute    | If you set Simplify to Yes and specify a value in this field the system uses this as the LUA data object name instead of the XML element name. | Text     | Optional           |
| Basic | Indentation                | For LUA to XML, this is the indentation text.                                                                                                  | Text     | Optional           |


---

# 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://community-test.logicnets.com/release-9/platform-documentation/process-node-parts/xml-converter.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.
