The input must be a valid JSON object with a single root key. XML requires a single root element, so your JSON must have exactly one top-level key. For example,
{
"spreadsheet": {
"name": "Sales Report",
"application": "Google Sheets",
"rows": 1500
}
}The output will be a well-formed XML document. For example, the output of the above input will be:
<?xml version="1.0" encoding="UTF-8"?>
<spreadsheet>
<name>Sales Report</name>
<application>Google Sheets</application>
<rows>1500</rows>
</spreadsheet>The following inputs will produce an error:
{"name": "Budget", "app": "Excel"}.Use the $ key to define attributes and the _ key for text content
when an element needs both. For example,
{
"workbook": {
"$": { "format": "xlsx", "app": "Excel" },
"sheet": "Q4 Revenue"
}
}This produces:
<?xml version="1.0" encoding="UTF-8"?>
<workbook format="xlsx" app="Excel">
<sheet>Q4 Revenue</sheet>
</workbook>