XML (Extensible Markup Language) is a tag-based markup format for representing structured, nested data, where every piece of content is wrapped in a named opening and closing tag. It's a W3C Recommendation, first published in 1998, and predates JSON as the dominant format for web APIs and configuration files.
An XML document is a tree of elements, each of which can have attributes and nested child elements:
<?xml version="1.0" encoding="UTF-8"?>
<book id="1">
<title>Structure and Interpretation</title>
<authors>
<author>Abelson</author>
<author>Sussman</author>
</authors>
</book>
A document is well-formed if it follows XML's syntax rules (every tag closed, attributes quoted, a single root element); it's valid if it additionally conforms to a schema — a DTD or an XSD (XML Schema Definition) — that constrains which elements, attributes, and nesting are allowed. XML supports namespaces (xmlns) so element names from different vocabularies can mix in one document without colliding, a feature JSON has no equivalent for. XML is also the basis for several derived formats still in wide use: SVG (vector graphics), RSS/Atom (feeds), and the zipped-XML internals of .docx/.xlsx files.
<book id="1">) or a child element (<book><id>1</id></book>) is a design choice XML doesn't enforce, and inconsistent APIs mix both.