XML (eXtensible Markup Language) is a markup specification developed by the W3C for storing and transporting structured data in a text-based, human-readable format. Unlike HTML, which focuses on presentation, XML is designed purely for data representation — it provides strict syntax rules (well-formedness), optional schema validation for structural integrity, and namespace mechanisms for avoiding element conflicts. Key consideration: while XML's flexibility and self-describing nature made it a standard for web services (SOAP), configuration files (Maven, Spring), and document formats (SVG, XHTML), its verbose syntax and parsing overhead have led many modern APIs to favor JSON; however, XML remains essential when schema validation, document processing (XPath/XSLT), and complex hierarchies are required.
What This Cheat Sheet Covers
This topic spans 19 focused tables and 135 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Core XML Syntax
| Element | Example | Description |
|---|---|---|
<?xml version="1.0" encoding="UTF-8"?> | • Optional first line specifying XML version (1.0 or 1.1) and character encoding (typically UTF-8) • the standalone attribute indicates whether external definitions are required (yes or no). | |
<book>Clean Code</book> | • Basic building block consisting of start tag, content, and end tag • element names are case-sensitive and must start with a letter or underscore | |
<br/> or <img src="logo.png"/> | • Self-closing tag with no content between opening and closing • the slash before > is mandatory for well-formedness | |
<book id="101" lang="en"> | • Name-value pair inside a start tag providing metadata about the element • attribute values must be quoted (single or double quotes). |