Why we still format XML in 2026
Plenty of software the world runs on every day is XML under the hood: the sitemap.xml Google needs to index your site, RSS feeds powering podcasts and newsletters, electronic invoices in countries like Argentina, Mexico and Spain, Microsoft Office files (which look binary but are zip archives full of XML), Spring Boot configs, SOAP responses in banking systems. When something breaks in any of these contexts, step one is inspecting the formatted XML.
Well-formed XML basics
- Single root. The whole document must sit inside one root element.
- Balanced tags. Every open tag has a matching close, in the right order.
<a><b></a></b>is invalid. - Quoted attributes.
id=1breaks;id="1"works. - Reserved characters escaped. Use
<,>,&inside content and attributes. - Case-sensitive.
<Book>and<book>are different tags.
XML vs JSON
JSON won the public web by a wide margin: it's terser, browsers parse it natively with JSON.parse, and almost every modern REST API uses it. But XML isn't dead. It does things JSON doesn't handle gracefully: namespaces, formal schemas via XSD for structure validation, mixed content (text intermixed with tags), CDATA for embedding content without escaping. In environments with formal contracts between systems (banking, government, healthcare), XML is still standard.
Typical errors the parser catches
- Unclosed tag.
<p>hello. - Misordered closing.
<b><i>text</b></i>. - Illegal character. An unescaped
¬ part of an entity. - Multiple roots. More than one element at the top level.
- Duplicate attribute.
<p class="a" class="b">.
Where formatting helps
- Auditing a sitemap. Verify all URLs are well-formed with consistent priorities.
- Debugging a SOAP response. SOAP services return huge XML — without formatting, finding the error takes forever.
- Editing Spring configs. When a teammate sends you a minified application.xml, step one is formatting it.
- Inspecting RSS feeds. If your feed doesn't validate in readers, formatting reveals the offending tag.
Productivity tips
For huge XML (over 10 MB) consider a desktop editor with streaming (XMLSpy, oXygen) instead of a browser. If you work with SOAP regularly, install the "XML Tree" Chrome extension: it shows a hierarchical tree with collapsible nodes. When converting XML to JSON, remember attributes have no direct mapping: libraries like xml2js put them under a special key (typically $ or @attr).