XMLTools.Stringify
Convert a Javascipt object to an XML string. The following object types are supported:
StringNumber(including NaN as "NaN")BigIntBooleanUndefined(as empty string)Object(including null as empty string)ArrayUndefined
This function accepts the following parameters:
| Parameter | Default value | Description | Required |
|---|---|---|---|
| Object | The JavaScript object to convert to an XML string. | yes | |
| Root | root | The root of the new XML string. | no |
| Allow Multiple Root | false | Determines whether the resulting XML string has multiple roots. Example: When this parameter is set totrue, the object [1, 2, 3] is converted to:<root>1</root><root>2</root><root>3</root> | no |
| Formatting | false | Determines 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>"
Updated 4 months ago
