About the XML Validator
An XML document is well-formed when it follows the syntax rules of XML 1.0: exactly one root element, every start tag closed by a matching end tag in the right order, attribute values in quotes, no attribute twice in one tag, and the characters < and & escaped in text. A parser must stop at the first violation, so unlike HTML there is no error recovery: one unescaped ampersand in a URL makes the whole document unreadable. This tool parses the input with the XML parser of your browser and reports the line and column of the first error, quotes the line, and translates the parser's message into what to change.
For a well-formed document the validator reports the root element, the number of elements and attributes, the nesting depth, comments, CDATA sections and processing instructions, the XML declaration, and every namespace declared with xmlns or xmlns:prefix. A prefix that is used without a declaration is an error in a namespace-aware parser, and it is reported as one. The second editor shows the document re-indented, which makes a structure problem such as an element closed one level too early easy to see.
Well-formed is not the same as valid. Validity means that the document also follows a grammar — a DTD, an XML Schema (XSD) or RELAX NG — that says which elements and attributes may appear where. That check needs the schema and is not done here. Only the five predefined entities (< > & " ') and numeric references work without a DTD, so is an error in plain XML. The document is processed in your browser and is not uploaded.
How to use it
- Paste your XML or open a file (.xml, .svg, .rss, .xsd, .plist…).
- Read the result above the editors: green means well-formed.
- If there is an error, go to the reported line and column and read the explanation.
- Fix it and continue: a parser reports one error at a time, so the next one appears after the first is gone.
Frequently asked questions
What is the difference between well-formed and valid XML?
Why is <code>&nbsp;</code> an error?
<, >, &, " and '. HTML entities such as or © exist only when a DTD declares them. Use the character itself or a numeric reference such as  .Why does the validator show only one error?
Does the XML declaration have to be there?
<?xml version="1.0" encoding="UTF-8"?> is optional in XML 1.0; without it the document is read as XML 1.0 in UTF-8 (or UTF-16 with a byte order mark). If it is present it must be the very first thing in the file, before any space or comment.