Glossary

XML

Extensible Markup Language — a verbose, self-describing text format with schema validation (XSD/DTD), namespace support, and transformation capabilities (XSLT). XML remains standard in enterprise systems, SOAP web services, SVG, RSS, and Microsoft Office formats.

XML (Extensible Markup Language) is a markup language derived from SGML that represents structured data using nested element tags. An XML document consists of elements (tags), attributes, text content, and optionally a Document Type Definition (DTD) or XML Schema (XSD) for validation. XML is self-describing, supports namespaces for avoiding naming conflicts, and is strictly well-formed — a single syntax error makes the document invalid.

Syntax

<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:dc="http://purl.org/dc/elements/1.1/">
  <book id="bk001">
    <dc:title>Developer Tools Reference</dc:title>
    <author>Cosyslabs</author>
    <price currency="USD">29.99</price>
    <description><![CDATA[Contains < > & characters safely]]></description>
  </book>
</catalog>

Rules

  • Every element must be properly nested and closed
  • Attribute values must be quoted (single or double)
  • <, >, &, ", ' must be escaped: &lt; &gt; &amp; &quot; &apos;
  • XML is case-sensitive: <Book> and <book> are different elements
  • A document must have exactly one root element
  • CDATA sections <![CDATA[...]]> allow unescaped special characters

XML vs JSON

FeatureXMLJSON
VerbosityHighLow
AttributesYesNo (use object keys)
CommentsYesNo
NamespacesYesNo
Schema validationXSD (complex)JSON Schema (simpler)
Best forDocuments, SOAP, SVGAPIs, configuration

Where XML Is Still Used

  • Office formats: DOCX, XLSX, PPTX are ZIP archives of XML files
  • SVG: Scalable Vector Graphics is XML-based
  • SOAP web services: legacy enterprise APIs
  • Maven: Java build configuration (pom.xml)
  • Spring: application context configuration
  • Android: layout files and AndroidManifest.xml
  • RSS/Atom feeds: blog syndication

XPath and XQuery

//book[@id='bk001']/price    # Select price of book with id bk001
//book[price > 20]/title      # Select titles of books costing over $20
count(//book)                 # Count all books

Format and validate XML with the XML Formatter Tool.