XMLTools.Stringify

Convert a Javascipt object to an XML string. The following object types are supported:

  • String
  • Number (including NaN as "NaN")
  • BigInt
  • Boolean
  • Undefined (as empty string)
  • Object (including null as empty string)
  • Array
  • Undefined

This function accepts the following parameters:

ParameterDefault valueDescriptionRequired
ObjectThe JavaScript object to convert to an XML string.yes
RootrootThe root of the new XML string.no
Allow Multiple Rootfalse

Determines whether the resulting XML string has multiple roots.

Example: When this parameter is set to true, the object [1, 2, 3] is converted to:
<root>1</root><root>2</root><root>3</root>
no
FormattingfalseDetermines whether the resulting XML includes endlines and whitespace. When this parameter is set to true, endlines and whitespace are included.no
Example
var xml = XMLTools.Stringify({ s: "string", i: 1, b: false, n: null, nan: NaN, o: { k: "v" }, u: undefined, a: [1,2,{o: { k: "v"}}]});
Example output
"<root> <a> <b>-1</b> </a> <key>Hello World</key> </root>"