getXML()function
getXML(data: Data, caller: AnyCaller = getXML): string
| Return | |
|---|---|
string | The serialized XML string. |
| Throws | |
|---|---|
unknown | RequiredError if a key is not a valid XML element name. |
unknown | RequiredError if a value cannot be converted to XML. |
Build an XML string from a data object.
- Only data objects can be converted directly because XML requires named root and child elements.
undefinedvalues are omitted from the output.- Nested data objects become nested XML elements.
Examples
getXML({ user: { name: "Alice", age: 30 } }) // "<user><name>Alice</name><age>30</age></user>"