Skip to main content
XMLDir

Search 309 pages — tools, formats, elements, namespaces, directory, comparisons, XPath, datatypes, glossary, parse errors, schema errors, use cases, blog and product.

Schemas and validity

Well-formed

A document that obeys XML's syntax rules: one root element, strictly nested tags, quoted attribute values, escaped markup characters.

Well-formedness is binary and non-negotiable. A document that fails it is not XML, and a conforming parser must report the error and stop rather than guessing — the specification calls this a fatal error, and it is the single biggest difference between XML and HTML.

It says nothing about whether the document is the right shape. A sitemap with no <loc> elements, an invoice missing every total, a feed whose dates are nonsense: all well-formed. That question is validity, and it needs a schema.

Defined in
XML 1.0 §2.1
Category
Schemas and validity
Also written
well-formedness

Shown, not asserted

All 2 claims are executed on every test run, against the same engines the tools use. If the behaviour changes, the test fails rather than this page quietly becoming wrong.

  • Nonsense in the right syntax is well-formed.

    document.xml
    <invoice><total>banana</total></invoice>

    What the engine returns

    Well-formed.
  • Correct-looking content in the wrong syntax is not.

    document.xml
    <invoice><total>100</invoice></total>

    What the engine returns

    Opening and ending tag mismatch: total line 1 and invoice (line 1)

What catches people out

  • Namespace correctness is a separate specification. An undeclared prefix parses cleanly and is still wrong.
  • Well-formedness errors are fatal by design. A parser that recovers from one is not conforming, however convenient that feels.
  • Encoding problems surface as well-formedness errors, because the parser cannot read the characters at all.

Get started

Bring order to the XML your team can't afford to ignore.

Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.