Bookmarks

XML — Extensible Markup Language

A format for storing and transmitting structured data: the author invents the names of tags and attributes, hence “extensible” in the name.

Also: XML file, XML document

checked 9 Nov

All terms

XML was developed by a W3C working group in 1996 as a simplified subset of SGML, so that data on the web could be transmitted and processed in the same way as HTML pages. The author defines the meaning of the tags, so XML is used for documents, configurations and messages between systems alike. The first edition of the XML 1.0 recommendation came out on 10 February 1998.

How a document is structured

A document starts with a declaration, followed by exactly one root element, which contains nested elements, their text and attributes:

xml
<?xml version="1.0" encoding="UTF-8"?><order id="1042">    <item sku="A-17">        <name>USB-C cable</name>        <qty>2</qty>    </item>    <total currency="USD">24.90</total></order>
  • Tags are case-sensitive: Name and name are different elements.
  • Special characters are written as entity references: &lt; instead of <, &amp; instead of &; text containing markup can be wrapped whole in a <![CDATA[…]]> section.
  • Comments look like <!-- … -->; spaces and line breaks inside elements are significant.
  • Identically named tags from different vocabularies are told apart with namespaces, through the xmlns attribute.

Schemas and correctness

A document without syntax errors is called well-formed: an unescaped < or an unclosed tag is a fatal error, and the parser must stop. Conformance to a schema is a separate property (valid): DTD, XML Schema (XSD) or RELAX NG describe which elements are allowed where and what types they have. A file can be checked against a schema automatically, for example with xmllint --schema.

Where it is used

WhereExamples
Configurationpom.xml in Maven, the Android manifest, web.config, Spring settings
Exchange between systemsSOAP envelopes, SAML assertions, RSS and Atom feeds
Documents and graphicsOffice formats (.docx, .xlsx) based on OOXML, vector graphics in SVG
Data processingqueries with XPath, transformations with XSLT

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • JSONJSON

    JSON is a compact format for exchanging data between web applications; XML is more verbose but supports attributes, mixed content, namespaces and schemas.

  • YAMLYAML

    YAML describes configurations with indentation, without tags; XML has a stricter syntax and more tooling for large documents.