Developer

XML Formatting and Common XML Errors Explained

ToolOrbit Engineering 2 min readUpdated
XML Formatting and Common XML Errors Explained

XML is still widely used in sitemaps, RSS feeds, SOAP APIs, and configuration files. But raw XML can be hard to read or easy to break with a missing closing tag. This guide shows how to format, validate, and convert XML safely, using the ToolOrbit XML Formatter & Validator.

When XML becomes hard to manage

  • Minified XML has no line breaks or indentation.
  • Mixed content and nested tags are difficult to scan visually.
  • Mismatched tags or missing closing elements break parsers.
  • Special characters must be escaped properly in text nodes and attributes.

Format, minify, or convert

ToolOrbit can pretty-print XML with consistent indentation, minify it for production, or convert it into JSON so you can work with it in modern apps. The formatter validates the XML first and reports syntax errors before it tries to rewrite the document.

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/</loc>
    <lastmod>2026-01-01</lastmod>
  </url>
</urlset>

Common XML problems

  • Unescaped & characters inside text nodes.
  • Missing closing tags on nested elements.
  • Confusion between attributes and child elements.
  • Incorrect encoding declarations for non-ASCII content.
Tip: If your XML contains a BOM or non-UTF-8 encoding, convert it to UTF-8 before using the formatter to avoid parser errors.

Why validation matters

A broken sitemap or RSS feed can stop search engines from crawling your site. Validating XML before publishing catches problems early, and ToolOrbit does it locally in your browser so you never expose private feeds or config files.

XML vs JSON: which side of the fence

A quick comparison
PropertyXMLJSON
Attributes on elementsYesNo (objects instead)
NamespacesFirst-classManual
CommentsNativeNot allowed
Comments side-by-sideCommon in configsUsually external

XML earns its keep in documents with attributes and namespaces (RSS feeds, SOAP, legacy configs). JSON wins where a parser must be dead simple. The formatter here keeps the XML exactly as authored — it only fixes the presentation, so you can trust it before a schema validation step.

A formatted but invalid document is still invalid — run the Validate action to catch unescaped ampersands and unclosed elements before a strict parser rejects the file downstream.

Minified XML has its moments

Formatted XML is for humans; minified is for payloads. API requests, storage and transfer all benefit from single-line XML with no whitespace, and the formatter can produce exactly that. Comment-stripping is the one part to treat with care — comments sometimes carry semantics for downstream tools, so only strip them when you know the receiver ignores them.

If the parser downstream expects a DOCTYPE or namespaces, keep the source-formatted copy to compare against — minifiers should never remove either.

Tools mentioned

More reading

View all guides
What Is Base64? How Encoding Works and Common Mistakes
Developer

What Is Base64? How Encoding Works and Common Mistakes

What Base64 encoding actually does, where it is used, and the mistakes that cause broken or oversized output.

2 min readUpdated
encodeURI vs encodeURIComponent: Which One to Use
Developer

encodeURI vs encodeURIComponent: Which One to Use

How percent-encoding works, the difference between encoding a whole URL and a single component, and the mistakes that break links.

2 min readUpdated
What Is a UUID? Version 4 vs Version 7 Explained
Developer

What Is a UUID? Version 4 vs Version 7 Explained

What a UUID looks like, why version 4 is the safe default, when version 7 is better, and best practices for IDs.

2 min readUpdated
How SHA-256 and SHA-512 Hashes Work: Hashing vs Encryption
Developer

How SHA-256 and SHA-512 Hashes Work: Hashing vs Encryption

What a hash function does, how to choose between SHA-256 and SHA-512, and why hashing is not encryption.

2 min readUpdated
What Is a JWT? Header, Payload and Signature Explained
Developer

What Is a JWT? Header, Payload and Signature Explained

A JSON Web Token has three parts. Learn what the header, payload and signature contain, how to read the claims, and why decoding is not verifying.

2 min readUpdated
What Is HTML Encoding? Entities & Escaping Explained
Developer

What Is HTML Encoding? Entities & Escaping Explained

Learn how HTML encoding works, why escaping prevents XSS and layout breaks, and how to encode and decode named, decimal, and hex entities.

2 min readUpdated
Unix Time Explained: Seconds, Milliseconds and Time Zones
Developer

Unix Time Explained: Seconds, Milliseconds and Time Zones

What a Unix timestamp is, how to tell seconds from milliseconds, how time zones come into it, and the values worth recognising.

2 min readUpdated
Binary, Octal, Decimal and Hex: How Number Bases Work
Developer

Binary, Octal, Decimal and Hex: How Number Bases Work

How positional number bases work, why very large values need exact arithmetic, and the hex and binary values you meet every day.

2 min readUpdated