XML, or Extensible Markup Language, is a text-based markup language designed for representing structured data and documents in a way that is both human-readable and machine-processable. Unlike HTML, XML does not prescribe a fixed vocabulary for general use; authors can define element and attribute names appropriate to their data model. An XML document consists of nested elements forming a tree, together with attributes, text nodes, processing instructions, comments and other constructs defined by the specification. XML's strict well-formedness rules require correctly nested elements, properly formed markup and appropriate document syntax. XML is therefore a framework for structured representation rather than a database, programming language or presentation system.
XML originated from SGML, the Standard Generalized Markup Language, while simplifying and constraining SGML's complexity for broader Internet use. XML 1.0 was developed by a W3C working group chaired by Jon Bosak and became a W3C Recommendation in 1998. The design drew on earlier markup practices while seeking portability, extensibility and straightforward parsing. XML subsequently became widely used for configuration files, document interchange, publishing, enterprise integration and numerous specialised vocabularies. Technologies such as XHTML, SVG, MathML, SOAP and RSS have used XML syntax or XML-derived representations, although many newer web APIs favour JSON for application data exchange.
XML's distinction between well-formedness and validity is important. A well-formed document obeys XML's syntactic requirements, including having appropriate element nesting and a single document element. A valid document additionally conforms to a declared vocabulary or schema when such a validation system is being applied. XML can be constrained using Document Type Definitions, XML Schema Definition, commonly called XSD, and other schema technologies such as RELAX NG. Namespaces provide a mechanism for preventing naming collisions when different XML vocabularies are combined. A namespace-qualified element can therefore be distinguished from another element having the same local name but belonging to a different namespace.
XML elements naturally form hierarchical trees, making XML particularly suitable for data or documents with nested structures. Attributes can express metadata or compact properties associated with an element, while child elements can represent more substantial structured content. XML supports character references, entity references, CDATA sections and namespaces. The distinction between element content and attributes is partly a modelling choice governed by the intended vocabulary and its schema. XML's syntax is verbose compared with compact serialisation formats because opening and closing tags normally repeat element names. That verbosity can increase document size but can also make structure explicit and readable, especially in document-oriented applications.
XML is frequently associated with a larger ecosystem of standards. XPath provides expressions for selecting nodes in XML trees, XSLT transforms XML documents into other representations, XQuery supports querying XML data, and XSL-FO has been used for document formatting workflows. XML Signature and XML Encryption address specialised security requirements. DOM and SAX are two historically important programming interfaces for processing XML: DOM builds an in-memory tree, while SAX uses event-driven parsing. Streaming approaches are important when documents are too large to load conveniently into memory. XML parsers may therefore expose substantially different processing models depending on application requirements.
XML has historically been important for interoperability because independent systems can exchange structured information without requiring the receiving system to share the sender's programming language or internal object model. Enterprise systems have used XML for messages, configuration, invoices, metadata and document interchange. SOAP web services, for example, use XML-based messaging conventions, while standards such as SVG use XML syntax to represent vector graphics. XML can represent mixed content, meaning text and nested markup can coexist within the same document, making it particularly appropriate for document publishing as well as purely data-oriented applications.
XML differs from JSON, YAML, HTML and Markdown in important ways. JSON is generally more compact and maps naturally to common programming-language data structures; YAML emphasises human-oriented configuration and supports features beyond JSON's basic data model; HTML has a predefined web vocabulary and specialised parsing behaviour; Markdown provides lightweight authoring syntax that is commonly converted into HTML. XML's advantages include extensibility, mature validation mechanisms, namespaces, mixed-content support, broad tooling and a large standards ecosystem. Its disadvantages include verbosity, parsing complexity, configuration overhead and security concerns associated with unsafe parser configurations, including historical external-entity vulnerabilities. Secure XML processing therefore requires careful control over external entities, resource resolution and parser behaviour.
XML remains relevant in areas where structured documents, schemas, namespaces or established standards require it, even though JSON has become dominant for many modern web APIs. An XML document can be transformed, validated, queried and processed by mature tools across numerous programming environments. Common misconceptions include treating XML merely as "HTML with custom tags" or assuming every XML document is automatically valid because it can be parsed. XML's value lies in its formal rules and extensibility, but those same characteristics can make it more elaborate than simpler serialisation formats. Its continued use is strongest where formal document structures, long-lived standards, interoperability requirements and rich metadata or document semantics justify that complexity.