1. Docs
  2. Formulas
  3. Functions

TO_XML

Converts an object into XML. The root element name is optional and defaults to hash. Formula lambdas run without access to the XML builder; other Ruby callbacks are rejected.

Categories: Data Parsing/Conversion

Syntax

TO_XML(object, [root_element_name])

Examples

Example 1

Input

1
{
2
"my_action": {
3
"object": {
4
"city": "Melbourne",
5
"country": "Australia",
6
"post_code": 3000,
7
"state": "Victoria"
8
}
9
}
10
}

Formula

TO_XML(my_action.object)

Output

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

Example 2

Input

1
{
2
"my_action": {
3
"object": {
4
"city": "Melbourne",
5
"country": "Australia",
6
"post_code": 3000,
7
"state": "Victoria"
8
}
9
}
10
}

Formula

TO_XML(my_action.object, "Data")

Output

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

Example 3

Input

{}

Formula

TO_XML({name: "Ada", callback: LAMBDA(options, key, key)})

Output

"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<hash>\n <name>Ada</name>\n</hash>\n"

Sample actions

Event Transform
My Action
Event Transform
TO_XML

Select an action to inspect

You can also click "Copy actions" and paste them in your Tines story to see how they work.

Was this helpful?