TExcelTAD
Home › XML › XML Intro

XML Introduction

XML stands for eXtensible Markup Language. It is a text format for describing data with tags that you invent yourself. Where HTML has a fixed set of tags (<p>, <h1>, <table> …) that tell a browser how to show content, XML has no predefined tags at all: you choose names such as <recipe>, <invoice> or <sensor> that say what the content is.

Here is a tiny XML document describing a weather reading:

xml · try it yourself
<?xml version="1.0" encoding="UTF-8"?>
<reading station="Harbour-3">
  <date>2026-03-14</date>
  <temperature unit="C">11.5</temperature>
  <wind direction="NW">22</wind>
  <summary>Cloudy with light rain</summary>
</reading>

Press ▶ Run. The playground hands the text to the browser's XML parser, which reports whether the document is well-formed (follows XML's grammar rules) and prints the tree of elements it found.

XML does nothing on its own

An XML file is just structured text. It doesn't display anything, send anything or calculate anything. Some program has to read it — a web page script, a server, a word processor, an e-reader — and decide what to do with the information. That separation is exactly the point: the same XML can be shown on a web page, printed, imported into a database or sent to another company's system.

XML vs HTML

HTML XML
Purpose Display content in a browser Store and transport data
Tags Fixed set defined by the standard Invented by the author
Error handling Very forgiving — browsers guess what you meant Strict — one mistake and the document is rejected
Case <P> and <p> are the same <Note> and <note> are different elements
Closing tags Some may be omitted (<li>, <p>) Every element must be closed

Note: XML is not a replacement for HTML. They were designed for different jobs and are often used together — for example, a page's script can load XML data and turn it into HTML.

Where you meet XML today

Even if you never write an .xml file by hand, XML is all around you:

  • Office documents — .docx, .xlsx and .pptx files are ZIP archives full of XML.
  • SVG graphics — every SVG image is an XML document.
  • News feeds — RSS and Atom feeds are XML.
  • Configuration — Android layouts, Maven pom.xml, .NET .csproj files, many server configs.
  • Data exchange — banking (ISO 20022), healthcare (HL7 CDA), publishing (DocBook, DITA), e-invoicing and many government systems.
  • Sitemaps — the sitemap.xml that tells search engines about a site's pages.

Self-describing data

Compare these two ways of storing the same fact:

text
Ada Lovelace,1815,London
xml · try it yourself
<person>
  <name>Ada Lovelace</name>
  <born>1815</born>
  <city>London</city>
</person>

The comma-separated line is compact, but you need outside knowledge to know what 1815 means. The XML version carries its own labels. A program — or a human reading the file years later — can understand it without a separate description. This is why XML is called self-describing.

Extensible

"Extensible" means you can add new elements without breaking the programs that already read the document. If a later version of the file adds <died>1852</died>, an older program that only looks for <name> and <born> keeps working — it simply ignores the element it doesn't know about.

Tip: In every playground on ExcelTAD you can edit the code and press Ctrl+Enter to run it. Try deleting the </city> closing tag above and run it again to see how strict the parser is.

What you will learn in this course

  1. The rules of XML syntax: elements, attributes, namespaces, entities and CDATA.
  2. How to check documents: well-formedness, DTDs and XML Schema.
  3. How to read and query XML in the browser with DOMParser, the DOM and XPath.
  4. How to change and build XML documents and turn them back into text.
  5. Real formats built on XML: RSS, SVG, and how XML compares with JSON.

Test yourself

What does XML stand for?

  1. Extra Markup Language
  2. eXtensible Markup Language
  3. eXecutable Modelling Language
  4. Example Markup Language

Which statement about XML tags is true?

  1. Only tags from the XML standard may be used
  2. They are the same as HTML tags
  3. The author of the document invents them
  4. They must all be written in capital letters

What happens when an XML file is opened by a program that doesn't use it?

  1. It runs automatically
  2. Nothing — XML is just structured text that some program must read
  3. It converts itself to HTML
  4. It deletes invalid data