XML

XML

An extensible markup language that expresses structure with tags

Introduction

XML (eXtensible Markup Language) is a markup language that expresses hierarchical structure by wrapping data in opening and closing tags. Because you can attach attributes to elements and strictly validate structure with a schema, it has long been used in documents and enterprise systems.

It is verbose but highly expressive, with a rich ecosystem including namespaces, schemas (XSD), and transformations (XSLT).

Syntax Features

Pros

  • Can be strictly validated with a schema
  • Highly expressive with attributes, namespaces, and more
  • A mature document ecosystem

Cons

  • Verbose due to repeated tags
  • Relatively heavy to parse
  • Losing ground to JSON in modern web APIs

Common Uses

Example

<?xml version="1.0" encoding="UTF-8"?>
<rows>
  <row>
    <id>1</id>
    <name>Ada</name>
    <role>admin</role>
  </row>
  <row>
    <id>2</id>
    <name>Linus</name>
    <role>editor</role>
  </row>
</rows>

Related Conversions