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:
- There is exactly one root element that contains all other elements.
- Every element is closed:
<name>…</name>, or self-closing like<br/>. - Elements are properly nested:
<b><i>…</i></b>, never<b><i>…</b></i>. - Names are case-sensitive:
<Item>and<item>are different elements. - Attribute values are always in single or double quotes.
&and<in text are escaped as&and<.- The optional declaration
<?xml version="1.0" encoding="UTF-8"?>must be at the very start.
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">.
| Element | Attribute | |
|---|---|---|
| Example | <color>red</color> | color="red" |
| Can repeat | Yes | No, once per element |
| Can contain child elements | Yes | No, only text |
| Order is significant | Yes | No |
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.
- DTD (Document Type Definition) is the original schema language, built into XML 1.0. It can also declare entities such as
. - XSD (XML Schema Definition) is itself written in XML and supports data types such as dates and decimals. E-invoice formats such as CFDI, NF-e and UBL publish XSD schemas.
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
| XML | JSON | HTML | |
|---|---|---|---|
| Purpose | Store and exchange structured data and documents | Exchange data, especially in web APIs | Display web pages |
| Tag or key names | Defined by you | Defined by you | Fixed by the HTML standard |
| Data types | Text, unless a schema defines types | String, number, boolean, null, array, object | Text |
| Attributes | Yes | No | Yes |
| Comments | Yes | No | Yes |
| Schemas | DTD, XSD | JSON Schema | – |
| Syntax errors | Rejected by parsers | Rejected by parsers | Repaired 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
- Sitemaps:
sitemap.xmltells search engines which pages a website has. - RSS and Atom feeds: news sites, blogs and podcasts publish their updates as XML.
- SVG: vector graphics on the web are XML documents.
- Office files: Office Open XML (DOCX, XLSX, PPTX) and OpenDocument (ODT, ODS) are ZIP packages of XML.
- E-invoices: CFDI in Mexico and NF-e in Brazil are XML files that must be digitally signed and authorized before they are legally valid; UBL is the XML format behind Peppol e-invoicing in Europe and beyond.
- SOAP web services: banks, payment providers and government systems exchange XML messages described by WSDL files.
- Android apps: layouts, string resources and
AndroidManifest.xmlare written in XML. - Configuration: Maven's
pom.xml, .NETweb.configand many other build and server settings.
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: