---
title: TO_XML
url: https://www.tines.com/docs/formulas/functions/to-xml/
kind: formula-function
---

*[tines.com](https://www.tines.com/llms.txt) › [Docs](https://www.tines.com/llms.txt) › [Formulas](https://www.tines.com/llm/docs/formulas.md) › [Functions](https://www.tines.com/llm/docs/formulas/functions.md)*

# TO_XML

*[View on tines.com](https://www.tines.com/docs/formulas/functions/to-xml/)*

Converts an object into XML, root element name is optional.

**Categories:** Data Parsing/Conversion

## Syntax

```
TO_XML(object, root_element_name = "hash")
```

## Examples

### Example 1

Input:

```json
{
  "my_action": {
    "object": {
      "city": "Melbourne",
      "country": "Australia",
      "post_code": 3000,
      "state": "Victoria"
    }
  }
}
```

Formula:

```
TO_XML(my_action.object)
```

Output:

```json
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<hash>\n  <city>Melbourne</city>\n  <state>Victoria</state>\n  <post-code type=\"integer\">3000</post-code>\n  <country>Australia</country>\n</hash>\n"
```

### Example 2

Input:

```json
{
  "my_action": {
    "object": {
      "city": "Melbourne",
      "country": "Australia",
      "post_code": 3000,
      "state": "Victoria"
    }
  }
}
```

Formula:

```
TO_XML(my_action.object, "Data")
```

Output:

```json
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Data>\n  <city>Melbourne</city>\n  <state>Victoria</state>\n  <post-code type=\"integer\">3000</post-code>\n  <country>Australia</country>\n</Data>\n"
```

## Sample actions

```json
{
  "standardLibVersion": "15",
  "actionRuntimeVersion": "4",
  "agents": [
    {
      "disabled": false,
      "name": "My Action",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "object": {
            "city": "Melbourne",
            "state": "Victoria",
            "post_code": 3000,
            "country": "Australia"
          }
        }
      },
      "position": {
        "x": 270,
        "y": 825
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    },
    {
      "disabled": false,
      "name": "TO_XML",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "to_xml": "=TO_XML(my_action.object)"
        }
      },
      "position": {
        "x": 270,
        "y": 930
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    }
  ],
  "links": [
    {
      "sourceIdentifier": 0,
      "receiverIdentifier": 1
    }
  ],
  "diagramNotes": []
}
```
