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 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:
Nameandnameare different elements. - Special characters are written as entity references:
<instead of<,&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
xmlnsattribute.
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
| Where | Examples |
|---|---|
| Configuration | pom.xml in Maven, the Android manifest, web.config, Spring settings |
| Exchange between systems | SOAP envelopes, SAML assertions, RSS and Atom feeds |
| Documents and graphics | Office formats (.docx, .xlsx) based on OOXML, vector graphics in SVG |
| Data processing | queries with XPath, transformations with XSLT |
Sources
the term is written from these pagesVerified 9 Nov