XML Guide
XML remains useful when structure and metadata need to be explicit
XML is verbose compared with JSON, but its strict nesting rules and attribute model still make it valuable for document-heavy and enterprise integrations.
Core concepts
Most XML mistakes come from breaking a small set of structural rules.
Elements
The main building blocks of the document, defined with start and end tags.
<title>Hello</title>Attributes
Small pieces of metadata attached directly to an element.
<book id=\"123\">Nesting
Elements must close in the reverse order they open so the tree stays valid.
<root><child /></root>Prolog
An optional header can declare the XML version and encoding.
<?xml version=\"1.0\"?>Syntax rules
XML parsers are intentionally strict, so malformed markup usually fails fast.
- Every document needs exactly one root element that contains everything else.
- Tags are case-sensitive, so
<Book>and<book>are different names. - Every opened element needs a matching closing tag unless it is self-closing.
- Attribute values must be quoted.
- Reserved characters like
<,&, and>must be escaped in text nodes where needed.
Typical places XML still shows up
- RSS and Atom feeds
- Sitemaps and search-related metadata
- SOAP integrations and enterprise messaging
- Office document bundles such as modern spreadsheet and document formats
- Configuration systems that rely on schemas or rich markup
XML vs HTML
These formats share angle-bracket syntax, but they solve different problems.
| Feature | XML | HTML |
|---|---|---|
| Purpose | Transport and store structured data | Render documents and interfaces |
| Tag set | User-defined | Predefined browser vocabulary |
| Error tolerance | Strict | Browsers recover from many mistakes |
| Closing tags | Required or self-closing | Some elements are implicitly closed |
Example document
library.xml
<?xml version="1.0" encoding="UTF-8"?>
<library>
<book id="1">
<title>The XML Guide</title>
<author>Jane Smith</author>
<price currency="USD">29.99</price>
</book>
<book id="2">
<title>Web Standards</title>
<author>John Doe</author>
<price currency="EUR">24.50</price>
</book>
</library>External references
Explore More
Keep moving through the docs
Jump between reference pages without leaving the product’s main visual system.