$$xml
Converts an object to XML string (a wrapper element can be added by specifying the field root
with the element name)
Optionally runs an XSLT over the result before returning it
Usage​
{
"$$xml": /* "XML structured" JSON object */,
"root": null /* string */,
"xslt": null /* string */,
"indent": false /* boolean */
}
"$$xml([root],[xslt],[indent]):{input}"
note
Concrete values in the usage example are default values.
Returns​
string
- XML String
Arguments​
Argument | Type | Values | Required / Default Value | Description |
---|---|---|---|---|
Primary | 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) | |
xslt | string | null | XSLT document to transform xml created from input | |
indent | boolean | false /true | false | Whether to pretty print the XML |
Examples​
Input
Definition
Output
{
"root": ""
}
"$$xml:$"
<root/>
{
"root": "",
"root_b": ""
}
"$$xml:$"
<root/><root_b/>
{
"root": "",
"root_b": ""
}
"$$xml(container):$"
<container><root/><root_b/></container>
{
"root": "",
"root_b": ""
}
"$$xml(container,,true):$"
<?xml version="1.0" encoding="UTF-8"?><container>
<root/>
<root_b/>
</container>
{
"root": ""
}
{
"$$xml": "$",
"root": "container"
}
<container><root/></container>
null
{
"$$xml": {
"hello": {
"hi": [
"",
""
],
"to": "world"
}
}
}
<hello><hi/><hi/><to>world</to></hello>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/container">
<my_record>
<first><xsl:value-of select="a" /></first>
<second><xsl:value-of select="b" /></second>
</my_record>
</xsl:template>
</xsl:stylesheet>
{
"$$xml": {
"a": "AAA",
"b": "BBB"
},
"root": "container",
"xslt": "$"
}
<?xml version="1.0" encoding="UTF-8"?><my_record><first>AAA</first><second>BBB</second></my_record>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" indent="yes"/><xsl:strip-space elements="*"/><xsl:template match="/"><xsl:copy-of select="."/></xsl:template></xsl:stylesheet>
{
"$$xml": {
"tag1": {
"value": "lorem"
},
"tag2": {
"items": [
{
"id": 1
},
{
"id": 2
}
]
}
},
"root": "root",
"xslt": "$"
}
<?xml version="1.0" encoding="UTF-8"?><root>
<tag1>
<value>lorem</value>
</tag1>
<tag2>
<items>
<id>1</id>
</items>
<items>
<id>2</id>
</items>
</tag2>
</root>