What is XML?

XML (Extensible Markup Language) is a text-based format for hierarchical data. It uses opening and closing tags — like HTML — but the tag names are defined by the author, not a fixed standard.

Structure

A minimal XML document:

<?xml version="1.0" encoding="UTF-8"?>
<users>
  <user id="1">
    <name>Alice</name>
    <email>alice@example.com</email>
  </user>
</users>

Every XML document must have exactly one root element. Tags are case-sensitive, and every opening tag must have a matching closing tag (or be self-closing: <br />).

Attributes vs Elements

Data can be stored as attributes (id="1") or as child elements (<name>Alice</name>). Convention: use attributes for identifiers and metadata, use elements for content — though both are technically equivalent.

Where XML Is Used

  • Configuration files — Maven (pom.xml), Android resources, .NET project files
  • Document formats — DOCX, XLSX, SVG, EPUB are all zipped XML
  • Enterprise integration — SOAP web services, EDI
  • RSS/Atom feeds — syndication formats for blogs and podcasts
  • Sitemapssitemap.xml tells search engines what to index

Convert XML to JSON or JSON to XML: Open XML ↔ JSON Converter →

Frequently Asked Questions

What is a well-formed vs valid XML document?

A well-formed document follows XML syntax rules (matching tags, quoted attributes, single root). A valid document is also well-formed AND conforms to a schema (DTD or XSD) that defines which tags and attributes are allowed. Validity is optional; well-formedness is required.

What is an XML namespace?

Namespaces prevent tag name collisions when combining XML from different vocabularies. A namespace is declared with xmlns="uri" and prefixed on tags: <svg:circle>. The URI is an identifier, not a URL that must resolve.

Related Terms

  • JSON — The modern, more concise alternative to XML for APIs.
  • YAML — A human-friendly structured data format.