XML uses nested elements delimited by opening and closing tags. A well-formed XML document has exactly one root element:
<?xml version="1.0" encoding="UTF-8"?>
<library>
<book id="1">
<title>Learning XML</title>
<author>Jane Smith</author>
<year>2023</year>
</book>
<book id="2">
<title>XML in Practice</title>
<author>John Doe</author>
<year>2024</year>
</book>
</library>
XML was designed to be self-descriptive. Unlike HTML, you define your own tag names to suit your data. It is widely used in configuration files (Maven, Spring, Android), SOAP web services, RSS/Atom feeds, SVG graphics, and document formats such as DOCX and ODT.
Validate whether a file is well-formed from the command line using xmllint (part of libxml2):
sudo apt install libxml2-utils
xmllint --noout library.xml && echo "Well-formed"