XML is routinely described as obsolete, which is strange given that you almost certainly opened several XML files today without noticing. It did lose the argument about sending data between programs — JSON won that decisively. It kept everything else.
XML stands for Extensible Markup Language. It looks like HTML, with one crucial difference: in HTML the tags are fixed and defined for you, while in XML you invent your own.
<book>
<title>Journey to the West</title>
<year>1592</year>
</book>
Nothing defines <book> in advance. The format gives you the grammar — tags, nesting, attributes — and you supply the vocabulary your data needs.
.docx is a zip archive full of XML; the text, the formatting and the structure are all XML files inside.That is not a legacy list. It is where XML turned out to be right.
This is the heart of the division, and it explains the whole situation in one example.
Consider a sentence with emphasis inside it: the quick brown fox, where only “quick” is italic. In XML that is natural:
<p>the <em>quick</em> brown fox</p>
Text and markup are interleaved — what XML calls mixed content. The element contains some text, then an element, then more text.
JSON has no way to express this. Its values are a string, a number, a list or an object; there is no concept of “text with things embedded at particular points”. Representing that sentence in JSON requires inventing a convention — an array of fragments, each tagged with its style — and then everyone must agree on your invention.
Documents are made of mixed content. Almost every sentence in a real document has something marked up inside it. That is why word processors, ebooks and page layouts are XML, and why they will stay XML.
Data is not like that. A price is a number, a name is a string, an order has a list of items. JSON fits that perfectly and XML merely adds punctuation.
<book id="42"> — metadata attached to an element rather than placed inside it.<!-- like this -->. JSON has none at all, which is a real inconvenience in configuration files.XML is stricter than HTML and far less forgiving:
<br> is invalid; <br/> is correct.<Book> and <book> are different elements.And then the one that causes more broken XML than all the others combined: the ampersand.
Five characters are reserved, and & is the dangerous one because it appears constantly in URLs. A web address with parameters contains & between them, and pasted raw into XML it makes the file invalid immediately. It must be written as &.
This is the usual cause of a sitemap or an RSS feed that a validator rejects: a single unescaped ampersand in a link. The other four are <, >, " and ', written as <, >, " and '.
For a block of text full of such characters, <![CDATA[ ... ]]> marks a region the parser should take literally — the standard way to put HTML inside an RSS feed.
Unlike CSV, XML solves the encoding problem properly. The first line declares it:
<?xml version="1.0" encoding="UTF-8"?>
The file states what it is, so nothing has to guess, and Chinese or Japanese content survives being moved between systems. It is a small thing that removes an entire category of failure.
XML is wordy — every value wrapped in an opening and closing tag, often with namespaces attached. For an API called a thousand times a second that is pure waste, and JSON is the right answer.
For a document that must be readable in thirty years, validated against a published standard, and interpreted identically by two organisations that have never spoken, the verbosity is doing work. The file describes itself, the schema defines what is legal, and nothing depends on a shared assumption that was never written down.
That is the division worth remembering: JSON for data in motion, XML for documents that must last.
& breaks the file — write &, especially in URLs