XML stands for “eXtensible Markup Language”. Before JSON took over, XML was the king of moving data between systems. It is more verbose, but it is still very much alive in banking, documents, RSS feeds, and a lot of enterprise software.
How it looks
XML uses opening and closing tags, much like HTML:
<person>
<name>Shravan</name>
<city>Cambridge</city>
<languages>
<language>C++</language>
<language>Python</language>
</languages>
</person>
Every tag you open, you must close. This makes XML wonderfully unambiguous —
but also chatty. Notice how name appears twice just to hold one value.
Tags can have attributes
You can attach extra info to a tag:
<book id="101" language="en">
<title>Some Title</title>
</book>
Here id and language are attributes. Should a piece of data be an attribute or its own child tag? That is one of those debates programmers can argue about for hours.
A common one: attributes for metadata (an id, a language, a unit), child elements for the actual content. It is a guideline, not a law — teams pick a convention and move on.
XML vs JSON, side by side
The same little record, in the old style and the new:
Why JSON mostly replaced it
Tag names repeat everywhere (open and close), so files get large. Parsing needs more ceremony.
Maps directly onto objects and arrays in nearly every language. For web APIs it is simply lighter and faster.
A little history
XML is genuinely old — it predates the modern web as we know it:
A W3C working group sets out to simplify SGML for the web.
Becomes a W3C recommendation and quickly takes over data exchange.
Lighter JSON gradually wins the web API world, but XML stays in documents and enterprise.
Where you still meet it
- RSS and sitemap feeds (this very website has an XML sitemap).
- Office documents (a
.docxfile is XML zipped up). - Older enterprise and banking systems.
You may not write XML often, but you will definitely read it someday. Think of it as a respected senior — old, a little formal, but still doing important work.