Tools
EN

What Is XML?

XML (Extensible Markup Language) is a text format for storing and exchanging structured data. This guide explains what XML means, how its syntax works, what an .xml file is and where you meet XML every day – from sitemaps and SVG images to Office documents and electronic invoices.

What XML means

XML stands for Extensible Markup Language. It became a W3C Recommendation in 1998 and describes data with tags that you name yourself – that is what “extensible” means. Unlike HTML, XML has no predefined tags: a catalog can use <product> and <price>, an invoice <item> and <total>.

A tiny XML document looks like this: <book id="1"><title>XML Basics</title><year>2026</year></book>. XML is plain text, so people can read it and every programming language can process it. It only stores and structures data – it does nothing by itself. Programs decide what the data means and how to display it.

XML syntax rules

Every XML document has to follow a few strict rules. A document that follows them is called well-formed:

Comments are written as <!-- … -->. An XML validator checks all of these rules in a second and points to the line of any error.

Elements and attributes

An element is a start tag, its content and an end tag: <price>19.90</price>. Elements can contain text, other elements or both. An attribute is a name–value pair inside the start tag: <price currency="EUR">.

ElementAttribute
Example<color>red</color>color="red"
Can repeatYesNo, once per element
Can contain child elementsYesNo, only text
Order is significantYesNo

A common convention: use elements for the data itself and for anything that can repeat or have structure, and attributes for metadata such as IDs, units or types.

Well-formed vs. valid XML

Well-formed XML follows the syntax rules; parsers refuse anything else. Valid XML is well-formed and also matches a schema that defines which elements and attributes are allowed, in which order and with which data types.

XML namespaces

Because anyone can invent tag names, two vocabularies may use the same name – the <title> of a book and the <title> of a person. Namespaces keep them apart by tying names to a URI. xmlns:cfdi="http://www.sat.gob.mx/cfd/4" declares the prefix cfdi, so <cfdi:Comprobante> belongs to the Mexican CFDI 4.0 vocabulary. A default namespace, xmlns="…" without a prefix, applies to every unprefixed element inside it. The URI is only an identifier; nothing is downloaded from it.

XML vs. JSON vs. HTML

XMLJSONHTML
PurposeStore and exchange structured data and documentsExchange data, especially in web APIsDisplay web pages
Tag or key namesDefined by youDefined by youFixed by the HTML standard
Data typesText, unless a schema defines typesString, number, boolean, null, array, objectText
AttributesYesNoYes
CommentsYesNoYes
SchemasDTD, XSDJSON Schema–
Syntax errorsRejected by parsersRejected by parsersRepaired by browsers

JSON is shorter and maps directly to objects in JavaScript, which is why most web APIs moved to it. XML remains strong where documents mix text and markup, need namespaces or must be validated strictly against schemas – which is why tax authorities, publishers and office formats still rely on it.

What is an .xml file and how do you open it?

An .xml file is a plain-text file that contains an XML document, usually encoded in UTF-8. Because it is text, any text editor can open it – Notepad on Windows, TextEdit on a Mac or a code editor such as VS Code. Chrome and Firefox display XML files as a tree when you drag them into a browser window, and Excel can import XML data into a spreadsheet.

Many files use XML without the .xml extension: .svg images, .rss feeds, .xsd schemas, .xsl stylesheets, .config files in .NET and .plist files on macOS, which can be stored as XML. Word, Excel and PowerPoint files (.docx, .xlsx, .pptx) are ZIP archives full of XML files.

Where XML is used

Frequently asked questions

What does XML stand for?

Extensible Markup Language. “Extensible” means that you define your own tags, and “markup” means that the structure is written as tags around the data.

Is XML a programming language?

No. XML is a data format: it describes and structures information but cannot compute anything. Related technologies such as XPath and XSLT query and transform it.

Is XML still used today?

Yes. JSON replaced XML in many web APIs, but XML remains the standard for sitemaps, RSS feeds, SVG, office documents, Android layouts, SOAP services and e-invoicing in many countries.

Updated: