XML (eXtensible Markup Language) is a markup format for structured data. XML is used in RSS feeds, Sitemaps, configuration files, SOAP APIs, and many enterprise systems. Formatting makes XML readable, while validation checks its syntax.
To format XML, use XML Formatter on reChecker.
What is XML
XML is a text format for representing data as a tree of elements. Unlike HTML, XML strictly follows a hierarchy and requires all tags to be closed.
Structure of an XML document:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<element attribute="value">
<child>Text content</child>
</element>
</root>Components:
- Declaration —
<?xml version="1.0" encoding="UTF-8"?>(optional, but recommended) - Root element — a single top-level element (required)
- Elements — tags with opening and closing parts
- Attributes —
ключ="значение"pairs inside the opening tag - Text — content between tags
Why format XML
Minified XML is a single line with no indentation:
<?xml version="1.0"?><rss version="2.0"><channel><title>My Blog</title><link>https://example.com</link><item><title>Post 1</title></item></channel></rss>The same XML after formatting:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>My Blog</title>
<link>https://example.com</link>
<item>
<title>Post 1</title>
</item>
</channel>
</rss>Formatting is useful for:
- Debugging — the structure is visible, making errors easier to find
- Editing — it is easier to add or remove an element
- Code review — readable XML is easier to review
- Documentation — XML examples in documentation should be readable
Uses of XML
RSS / Atom
Content syndication formats. News aggregators, Telegram bots, and other services read RSS to get updates from blogs and websites.
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>reChecker Blog</title>
<link>https://rechecker.ru/blog</link>
<description>Статьи об SEO и веб-инструментах</description>
<item>
<title>SQL Formatter: форматирование запросов</title>
<link>https://rechecker.ru/blog/sql-formatter-guide</link>
<pubDate>Fri, 14 Mar 2026 10:00:00 +0300</pubDate>
</item>
</channel>
</rss>Sitemap.xml
Google and Yandex use sitemap.xml to discover website pages. It is an XML file containing a list of URLs and metadata.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://rechecker.ru/</loc>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://rechecker.ru/services/sql-formatter</loc>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
</urlset>To validate and check a Sitemap: Sitemap checker.
Configuration files
XML is used in Maven configurations (pom.xml), Android (AndroidManifest.xml), Spring, JUnit, Log4j, and many other Java/Enterprise systems.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<database>
<host>localhost</host>
<port>5432</port>
<name>myapp</name>
<pool>
<min>5</min>
<max>20</max>
</pool>
</database>
<cache>
<ttl>3600</ttl>
<enabled>true</enabled>
</cache>
</configuration>SOAP API
SOAP (Simple Object Access Protocol) is an XML-based protocol for web services. It predates REST but is widely used in banking and ERP systems.
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetUserRequest>
<UserId>42</UserId>
</GetUserRequest>
</soap:Body>
</soap:Envelope>Rules for valid XML
1. One root element
An XML document must have exactly one root element:
<!-- Неверно — два корневых элемента -->
<users>...</users>
<orders>...</orders>
<!-- Верно -->
<data>
<users>...</users>
<orders>...</orders>
</data>2. All tags must be closed
Unlike HTML, XML does not have “unclosed” tags:
<!-- Неверно -->
<br>
<img src="logo.png">
<!-- Верно -->
<br/>
<img src="logo.png"/>3. Attributes must be quoted
Attribute values must be enclosed in single or double quotes:
<!-- Неверно -->
<item id=42 active=true>
<!-- Верно -->
<item id="42" active="true">4. Escaping special characters
The characters <, >, &, ", ' in text and attributes must be escaped:
| Character | Replacement |
|---|---|
< | < |
> | > |
& | & |
" | " |
' | ' |
<!-- Неверно -->
<title>Книга: "Война & Мир" </title>
<!-- Верно -->
<title>Книга: "Война & Мир"</title>5. Tag name case matters
XML is case-sensitive: <User> and <user> are different tags.
<!-- Ошибка: открыт как User, закрыт как user -->
<User>Ivan</user>
<!-- Верно -->
<User>Ivan</User>6. Namespaces
XML supports namespaces to avoid name conflicts when combining documents:
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>...</url>
</root>Common XML errors
| Error | Cause | Fix |
|---|---|---|
XML or text declaration not at start | Spaces or a BOM before <?xml | Remove spaces at the beginning of the file |
Entity 'amp' not defined | Unescaped & | Replace & with & |
Mismatched tag | Tag opened as <Item> and closed as </item> | Check the case |
Attribute without quotes | <tag id=5> | Add quotes: id="5" |
Multiple root elements | Multiple top-level elements | Wrap them in a single root element |
XML vs. JSON
| Property | XML | JSON |
|---|---|---|
| Readability | More verbose, but structured | More compact |
| Attributes | Embedded in the tag | Only through nested objects |
| Comments | Supported | Not supported |
| Size | Larger due to tags | Smaller |
| Data types | Everything is a string | Numbers, booleans, null |
| Uses | RSS, Sitemap, SOAP, configs | REST APIs, web |
XML tools
Online
XML Formatter on reChecker — formatting, minification, and validation. Everything runs in the browser; data is not sent to a server.
VS Code
The XML extension (Red Hat) adds highlighting, validation, and formatting. Shift+Alt+F — format the file.
Command line
# xmllint (Linux/macOS)
xmllint --format input.xml > output.xml
# xmllint с валидацией
xmllint --valid input.xml
# Python
python3 -c "import sys,xml.dom.minidom; print(xml.dom.minidom.parse(sys.argv[1]).toprettyxml())" input.xmlNode.js
import { XMLParser, XMLBuilder } from 'fast-xml-parser';
const parser = new XMLParser({ ignoreAttributes: false });
const json = parser.parse(xmlString);
const builder = new XMLBuilder({ format: true });
const formatted = builder.build(json);Conclusion
XML remains a relevant format for RSS, Sitemaps, SOAP, and configuration files. Formatting makes XML readable, while validation helps detect syntax errors before the file is applied. Use XML Formatter to work with XML quickly in your browser.