What is XML?
The markup format that predates JSON in most enterprises: elements, attributes, why it has no arrays, and how it maps onto JSON.
6 minute read · Updated August 2026A document format doing a data job
XML describes a tree of elements. Each element has a name, optional attributes, and children that may be further elements or text. It was designed for documents — mixed content, where text and markup interleave — and was later adopted for data interchange, which is why some of its features feel oversized for an API payload.
What it brings that JSON does not: namespaces for combining vocabularies, XSD and DTD for validating structure, XPath for addressing nodes, and XSLT for transforming whole documents. In regulated and enterprise systems those are frequently the reason XML is still in use.
<?xml version="1.0" encoding="UTF-8"?>
<root>
<service>checkout-api</service>
<orders>
<id>ord_101</id>
<status>paid</status>
<total>129.5</total>
<currency>USD</currency>
</orders>
<orders>
<id>ord_102</id>
<status>failed</status>
<total>42</total>
<currency>USD</currency>
</orders>
</root>There is no array, only repetition
This is the single most important difference from JSON. XML expresses a list by repeating an element name — the two <orders> elements above are a list only because they share a name and a parent. Nothing in the document says so.
The consequence bites on the way back. A converter reading XML with one <orders> element cannot tell whether the source was a one-element list or a single object, because both serialise identically. Any XML-to-JSON mapping has to pick a rule, and the rule is a guess unless a schema is present to say which elements repeat.
Attributes versus elements
XML stores a value in two different places — as an attribute on an element, or as a child element — and the format takes no position on which you should use. JSON has one place. So every XML-to-JSON converter invents a convention for attributes, commonly an @ or $ prefix on the key, and every such convention is a private extension rather than a standard.
Also unlike JSON, XML has no numbers or booleans. Every leaf is text until something external — a schema, or the consuming code — decides otherwise.