Fix XML invalid syntax

XML must be well-formed: every opening tag must have a closing tag, attributes must be quoted, and special characters escaped.

XML parsers fail fast on the first well-formedness error. Unlike HTML, tags must be properly nested and attributes must be quoted in most cases.

Common causes

  • Unclosed or crossed tags (`<a><b></a></b>`).
  • Unquoted attribute values containing spaces or special characters.
  • Raw `<`, `>`, or `&` in text nodes without entities.

How to fix

  • Match every start tag with an end tag in LIFO order.
  • Quote attribute values (`id="x"`).
  • Escape characters: `&lt;`, `&gt;`, `&amp;`, and quotes inside attributes as needed.

Use our tool

Validate XML

Advertisement

All guides