Introduction

XML stands for eXtensible Markup Language. Like HTML, it's built from tags — but where HTML has a fixed vocabulary (<p>, <div>, <img>) for describing a webpage, XML lets you invent your own tags to describe whatever data you're working with.

Self-describing data

There's no predefined list of XML tags. If you're describing a recipe, you might write <ingredient> and <step>. If you're describing a music library, you might write <track> and <artist>. The tag names exist purely to describe the meaning of the data they wrap — "extensible" refers to exactly this: you extend the language with whatever vocabulary your data needs.

XML recipe.xml
<recipe>
  <name>Pancakes</name>
  <servings>4</servings>
  <ingredient>flour</ingredient>
  <ingredient>eggs</ingredient>
  <ingredient>milk</ingredient>
</recipe>

Nothing here is built into XML itself — <recipe> and <ingredient> are just names this particular document's author chose. A different document, describing something else entirely, would invent entirely different tags.

XML describes data, not appearance

HTML tells a browser how to display something — <h1> renders as a large heading. XML makes no claim about display at all; a plain <ingredient> tag doesn't tell anything how to show that ingredient on screen, print it, or style it. XML's only job is to structure and label data. What happens with that data — displaying it, storing it, transforming it into something else — is entirely up to whatever program reads the XML afterward.

Where you'll actually run into XML

XML shows up less on the visible web than it did in the early 2000s, but it hasn't gone away — it's the format underneath Microsoft Word/Excel files (a .docx is literally a zip archive full of XML), RSS/Atom feeds, Android UI layout files, SVG images, and a long list of enterprise and government data-interchange standards.

Note: XML doesn't do anything by itself. A browser automatically renders HTML the moment it loads a page, but a plain XML file opened in a browser just shows you the raw tags (or a generic tree view) — nothing happens until some program is specifically written to read that XML and act on it.