Definition:
XML is a markup language that represents documents and data through elements, attributes and text organised in a hierarchical structure. Its name stands for Extensible Markup Language. The W3C XML 1.0 specification sets out the rules of its syntax.
Unlike a vocabulary with predefined tags, XML allows element names to be defined to suit each application. These names describe the structure, but do not in themselves indicate how the information should be processed or displayed. Systems exchanging a document need to share the conventions of its format.
It can be read as text and processed by software. It is used in documents, data exchanges and web services. It is neither a programming language nor a database; it provides a way to represent information that other applications can use.
Applications of XML
Different formats use XML syntax for specific purposes. RSS and Atom distribute content updates; SOAP defines a message structure for web services; and XHTML expresses an HTML vocabulary using XML rules. Sharing a syntax does not make these formats equivalent.
XML is also used in office documents. Office Open XML, used in files such as DOCX or XLSX, and OpenDocument, used by applications such as LibreOffice, organise information through XML components. These files can be packages containing several documents and other resources, rather than a single XML text file.
Other examples include SVG for vector graphics and XMPP, which uses XML in communication between entities on a network. Its usefulness depends on the vocabulary and protocol that establish how to interpret its elements.
Configuration files for .NET Framework applications can also use XML. This is a specific use within that framework, not a rule requiring every program or platform to store its configuration in that format.
Data exchange and XML
An XML document organises its elements within a root element. Tags must be correctly nested, attribute values are enclosed in quotation marks, and names are case-sensitive. An element can contain text, other elements or a combination of both.
This example represents a product with an identifier and a price:
<product id="A1">
<name>Notebook</name>
<price currency="EUR">4.50</price>
</product>
The syntax makes it possible to recognise elements and attributes, but the application needs to know what each one means. The text 4.50 does not automatically acquire a numeric type because it appears inside a tag called price; a schema and the system’s rules can define how to validate and interpret it.
A well-formed document complies with XML’s syntax rules. Validation adds a check against a structural definition, such as a DTD or an XSD schema, when one is used. A document can be well-formed without complying with the schema an application expects.
Namespaces distinguish vocabularies that use the same names. Their identifiers do not have to be pages that are downloaded when processing the document. Tools such as XPath select parts of the structure, while parsers and APIs help read and work with it.
When XML is sent over the Internet, the media type communicates what kind of content is being transmitted. RFC 7303 defines application/xml and recognises text/xml as an alias; it does not declare the latter obsolete. It also establishes the +xml suffix for specific XML-based types, such as image/svg+xml.
The media type does not replace agreement on the meaning of the data. The declared encoding must be consistent with the bytes sent, and both systems need to understand the vocabulary, its version and the expected fields. XML is one option for data exchange alongside formats such as JSON; the choice depends on the requirements and participating systems.
Recommendations for using XML
RFC 3470, identified as IETF BCP 70, sets out considerations for using XML in network protocols and applications. It is a design guide, not a guarantee that every implementation will be efficient or interoperable.
Defining the vocabulary, required fields and validation rules helps different applications interpret documents consistently. It is also useful to plan how new elements or versions will be introduced without breaking existing exchanges.
Processing must be appropriate to the origin and size of the documents. Parsers may offer functions to resolve external entities or load additional resources; restricting these when they are unnecessary helps prevent unintended access. Size and expansion limits also matter when receiving documents from external sources.
XML does not encrypt or authenticate data simply by structuring it. Protecting an exchange depends on the transport and the mechanisms applied. Similarly, validating the structure does not prove that the information is true or that the sender is legitimate.
