Malformed XML File
Download a free malformed XML file containing common XML well-formedness violations. Includes unclosed tags, mismatched tag nesting, unescaped ampersands, invalid attribute quoting, and duplicate attributes. Use it to test XML parsers, SOAP service error handling, and XML validation pipelines.
What Is Broken
Multiple XML well-formedness violations: unclosed <item> tags, mismatched nesting (<b><i></b></i>), unescaped & characters in text content, attributes without quotes, duplicate attributes on the same element, and an invalid XML declaration.
Broken Example
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<item id="1">
<name>Widget & Gadget</name>
<price currency=USD>29.99</price>
<description>A <b>great <i></b>product</i></description>
<item id="2">
<name>Another Item</name>
</item>
</catalog>Why It Matters
Unlike HTML, XML parsers are required to reject malformed documents. Any application that processes XML — SOAP services, RSS feeds, configuration files, data imports — must handle malformed input gracefully. Uncaught XML parsing errors can crash applications or cause data loss.
Expected Parser / Validator Behavior
All XML parsers should reject this document with a well-formedness error. DOM parsers should throw an exception. SAX parsers should call the error handler. The error message should identify the first violation and its position.
Related Invalid Files
Related Validators & Tools
Valid Sample Files
Frequently Asked Questions
What is XML well-formedness?
A well-formed XML document has properly nested and closed tags, escaped special characters, quoted attributes, and a valid XML declaration. Any violation makes the entire document unparseable.
How is this different from HTML?
HTML parsers are lenient and fix errors automatically. XML parsers are strict — any well-formedness error must cause a fatal error per the XML specification.