- Every document gets a single root
- XML permits exactly one top-level element. An object with several top-level keys, or an array of any length, therefore has to be wrapped, by default in <root>. A top-level array additionally needs a name for each entry, since XML has no anonymous list; each element becomes <item> unless you rename it.
- Keys that are not legal element names get rewritten
- XML names must start with a letter or underscore and cannot contain spaces or most punctuation. A key like "2024" becomes <_2024>, "first name" becomes <first_name>, and anything beginning with "xml" is prefixed because that string is reserved by the specification. A warning lists what changed, the rewrite is not reversible, so converting back will not restore the original key.
- Special characters are escaped
- The characters &, <, > and quotes in attribute values are replaced with their entity references, so a value containing markup cannot break the document structure. This means output is always well-formed regardless of what your strings contain.
- null becomes an empty element
- XML has no null, so null is written as an empty element: <score/>. That is indistinguishable from an empty string, so the distinction is lost. Schemas that need explicit nullability normally use the xsi:nil="true" attribute, which this converter does not add automatically.
- Types are not preserved
- XML content is text. The number 42, the string "42" and the boolean true all serialise identically, so type information exists only in a schema. Converting back applies inference and may not reproduce the original JSON types exactly.