XML
XML (Extensible Markup Language) is the W3C-standard markup language describing data with a tag tree, supporting namespaces, schema validation, and style transformation.
Purpose
To provide a self-describing, validatable, transformable document exchange format for scenarios needing strict structure and a rich tool ecosystem.
Mechanism
A document consists of a declaration, elements (<tag>content</tag>), attributes, comments, CDATA, and processing instructions. Namespaces declared with xmlns avoid tag collisions. Structure can be validated by DTD or XSD, and XSLT transforms documents.
Use cases
- SOAP web services
- SVG vector graphics
- Office documents (.docx is ZIP+XML)
- Configuration and manifests (pom.xml, AndroidManifest)
Examples
- Input
<person><name>Ada</name></person>OutputThe tree {person:{name:"Ada"}}Nested tags
Common errors
- Unescaped < > & breaks parsing
- Escape them with the entities < > &
Related terms
JSON
JSON (JavaScript Object Notation) is a lightweight data interchange format based on JavaScript object literals, using key-value pairs and arrays. GLOSSARY
YAML
YAML (YAML Ain't Markup Language) is a configuration-oriented data serialization format using indentation for hierarchy, supporting comments and references, and better suited to hand editing than JSON. GLOSSARY
XSD
XSD (XML Schema Definition) is the W3C-standard language for defining XML document structure, describing elements, attributes, and type constraints in XML syntax. GLOSSARY
DTD
A DTD (Document Type Definition) is the structure-definition mechanism of XML 1.0; it is simpler than XSD but limited, and is written in a special (non-XML) syntax. GLOSSARY
JSON Schema
JSON Schema is a vocabulary for describing the structure of JSON documents, defining types, constraints, and validation rules; it is the schema standard for JSON. GLOSSARY