Tech

What is XML?

Published
Published:
Table of Contents

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>
Everything must close

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

XML's weight

Tag names repeat everywhere (open and close), so files get large. Parsing needs more ceremony.

JSON's lightness

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:

1996
Work begins

A W3C working group sets out to simplify SGML for the web.

1998
XML 1.0

Becomes a W3C recommendation and quickly takes over data exchange.

2001+
The JSON era

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 .docx file is XML zipped up).
  • Older enterprise and banking systems.
Treat it with respect

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.

Support this post Sponsor