Skip to main content

$$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": /* value */,
"root": /* container name */,
"xslt": /* transformation spec */
}
"$$xml([root]):{input}"

Returns​

string (XML String)

Arguments​

ArgumentTypeValuesRequired / Default ValueDescription
PrimaryobjectYes"XML structured" JSON object
rootstringAdd a wrapper element with that name
xsltstringTransform result XML with the given XSLT document

Examples​

Input

Definition

Output (String)

{
"hello": {
"hi":[
"",
""
],
"to": "world"
}
}
{ 
"$$xml": "$"
}
<hello>
<hi/><hi/>
<to>world</to>
</hello>
{
"a": "",
"b": ""
}
{ 
"$$xml": "$"
}
<a/><b/>
{
"a": "",
"b": ""
}
{ 
"$$xml": "$"
"root": "x"
}
<x>
<a/>
<b/>
</x>
<?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": "x",
"xslt": "$"
}
<?xml version="1.0" encoding="UTF-8"?>
<my_record>
<first>AAA</first>
<second>BBB</second>
</my_record>
{
"hello": {
"hi": [ "", "" ],
"to": "world"
}
}
"$$xml:$"
<hello>
<hi/>
<hi/>
<to>world</to>
</hello>
{
"a": "",
"b": ""
}
"$$xml:$"
<a/>
<b/>
{
"a": "",
"b": ""
}
"$$xml(x):$"
<x>
<a/>
<b/>
</x>
{
"tag1": {
"value":"lorem"
},
"tag2": {
"items": [
{
"id": 1
},
{
"id": 2
}
]
}
}
{
"$$xml": "$",
"root":"root",
/* "XSLT does prettify" */
"xslt": "<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 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>