$$xml
Converts an object to XML string (a wrapper element can be added by specifying the field root with the element name)
Usage​
{
"$$xml": /* "XML structured" JSON object */,
"root": null /* string */,
"indent": false /* boolean */,
"attr_prefix": "@" /* string */,
"cdata_prop_name": "#text" /* string */
}
"$$xml([root],[indent],[attr_prefix],[cdata_prop_name]):{input}"
note
Concrete values in the usage example are default values.
Returns​
string - XML String
Arguments​
| Argument | Type | Values | Required / Default Value | Description |
|---|---|---|---|---|
| Input | object | Yes | "XML structured" JSON object | |
root | string | null | Name for a wrapper element (e.g. an array was passed and a container is needed) | |
indent | boolean | false/true | false | Whether to pretty print the XML |
attr_prefix | string | "@" | Prefix for properties to be used as XML attributes | |
cdata_prop_name | string | "#text" | A key for the text/CDATA section (when needed) |
Examples​
Input
Definition
Output
{
"root": ""
}
"$$xml:$"
<root/>
{
"root": "",
"root_b": ""
}
"$$xml:$"
<root/><root_b/>,<root_b/><root/>
{
"root": "",
"root_b": ""
}
"$$xml(container):$"
<container><root/><root_b/></container>,<container><root_b/><root/></container>
{
"root": "",
"root_b": ""
}
"$$xml(container,true):$"
<container>
<root/>
<root_b/>
</container>
,<container>
<root_b/>
<root/>
</container>
{
"root": ""
}
{
"$$xml": "$",
"root": "container"
}
<container><root/></container>
null
{
"$$xml": {
"hello": {
"hi": [
"",
""
],
"to": "world"
}
}
}
<hello><hi/><hi/><to>world</to></hello>
null
{
"$$xml": {
"hello": {
"@attr": "value",
"#text": "my data",
"to": "world"
}
}
}
<hello attr="value">my data<to>world</to></hello>