XML stands for eXtensible Markup Language. It is a markup language designed to store and transport data in a human-readable, self-describing format. Unlike HTML, XML has no predefined tags — you define your own tags to describe the structure and meaning of your data. XML is a W3C standard and forms the backbone of countless file formats and enterprise systems.
Need to format or validate an XML document?
Open XML Formatter →XML was developed by the XML Working Group of the World Wide Web Consortium (W3C) as a simplified subset of SGML (Standard Generalized Markup Language). It became a W3C Recommendation on 10 February 1998. In the early 2000s XML was the dominant format for web data exchange and web services (SOAP). Although JSON has taken over for most REST APIs, XML remains essential in document formats (DOCX, SVG, RSS), enterprise middleware, and configuration-heavy ecosystems like Java's Maven.
An XML document begins with an optional declaration that specifies the version and character encoding. The rest of the document is a tree of elements. Every element has an opening tag, optional content or child elements, and a closing tag. Elements can carry attributes inside the opening tag.
<?xml version="1.0" encoding="UTF-8"?>
<library>
<book id="1" available="true">
<title>Clean Code</title>
<author>Robert C. Martin</author>
<year>2008</year>
</book>
<book id="2" available="false">
<title>The Pragmatic Programmer</title>
<author>Andrew Hunt</author>
<year>1999</year>
</book>
</library>
<?xml version="1.0" encoding="UTF-8"?> — optional but recommended; specifies XML version and encoding<tag> and a closing tag </tag>. Empty elements can be self-closing: <br /><book id="1"><!-- This is a comment --><![CDATA[ <raw> content ]]>xmlns:ns="http://example.com"An XML document is well-formed when it follows all syntax rules: exactly one root element, all tags properly closed and nested, attributes quoted, and special characters escaped. A well-formed document can be parsed by any XML parser.
A document is also valid when it conforms to a schema — either a DTD (Document Type Definition) or an XSD (XML Schema Definition). Schemas define which elements and attributes are allowed, their data types, and their order.
Five characters have special meaning in XML and must be escaped when used inside text content or attribute values:
& — & (ampersand)< — < (less-than)> — > (greater-than)" — " (double quote, in attributes)' — ' (apostrophe, in attributes)pom.xml), Android layouts, Spring Framework beans, Ant build scriptssitemap.xml for search engines, RSS feeds for content syndicationJSON has largely replaced XML for REST APIs, but XML retains advantages in specific areas:
Choose JSON for web APIs and application data. Choose XML when you need document-centric formats, schemas, SOAP services, or when integrating with enterprise systems that mandate XML.
<Book> and <book> are different elements&, <, >, ", ') must be escapedXML (eXtensible Markup Language) is a markup language designed to store and transport data in a human-readable, self-describing format. Unlike HTML, XML tags are not predefined — you define your own tags to describe the structure and meaning of your data.
XML stands for eXtensible Markup Language. It was developed by the W3C and became a W3C Recommendation in 1998.
XML is used for configuration files (Maven pom.xml, Android layouts), document formats (DOCX, ODT, SVG), data exchange in SOAP web services, RSS and Atom feeds, and storage in many enterprise systems.
HTML is designed for displaying data in a browser and has predefined tags. XML is designed for storing and transporting data with user-defined tags. XML is strict about well-formedness — all tags must be closed and properly nested. HTML is more lenient.
JSON is shorter, easier to read and natively supported in JavaScript, making it the dominant choice for REST APIs. XML supports attributes, namespaces, comments and schemas (XSD/DTD) and is still preferred for document-centric formats, SOAP services and enterprise integrations.
A well-formed XML document follows all XML syntax rules: it has exactly one root element, all tags are properly closed and nested, attributes are quoted, and special characters are escaped. Any XML parser can process a well-formed document.