SyntaxStudy
Sign Up
XML What Is XML and Why It Matters
XML Beginner 1 min read

What Is XML and Why It Matters

XML, which stands for Extensible Markup Language, is a text-based format designed to store and transport structured data in a way that is both human-readable and machine-readable. It was standardized by the W3C in 1998 as a simplified subset of SGML. Unlike HTML, which defines a fixed set of tags for presentation, XML lets authors define their own tag names to describe the meaning of the data they contain. XML is platform- and language-independent, making it ideal for data interchange between heterogeneous systems. It underpins technologies such as XHTML, SVG, RSS, SOAP, and the Office Open XML format used by Microsoft Office. Configuration files for many Java enterprise applications — including Maven and Spring — are written in XML. A core distinction in XML is between well-formed and valid documents. A well-formed document obeys the basic syntactic rules of XML: every opening tag has a matching closing tag, elements are properly nested, attribute values are quoted, and there is exactly one root element. A valid document is also well-formed but additionally conforms to a schema or DTD that constrains which elements and attributes are allowed and in what order.
Example
<?xml version="1.0" encoding="UTF-8"?>
<!-- A simple well-formed XML document describing a bookstore -->
<bookstore>
    <book category="fiction">
        <title lang="en">The Great Gatsby</title>
        <author>F. Scott Fitzgerald</author>
        <year>1925</year>
        <price currency="USD">12.99</price>
    </book>
    <book category="non-fiction">
        <title lang="en">Clean Code</title>
        <author>Robert C. Martin</author>
        <year>2008</year>
        <price currency="USD">35.00</price>
    </book>
    <!--
        Rules that make this document well-formed:
        1. Single root element <bookstore>
        2. Every tag is properly closed
        3. Elements are correctly nested (no overlapping)
        4. Attribute values are enclosed in quotes
        5. XML declaration at the top (optional but recommended)
    -->
</bookstore>