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.

Parsing and processing

Parser

The component that reads XML text and reports its structure to an application, or reports a fatal error and stops.

The specification calls it a processor and gives it one hard obligation: on a well-formedness error it must report the error and must not continue passing normal parsed data to the application. That is why XML tooling fails loudly where HTML tooling guesses.

Which parser you run changes the wording you see, not the verdict. This site runs libxml2, which is also what PHP's DOM and SimpleXML, Python's lxml and Ruby's Nokogiri use underneath — so the message on an error page here is usually the message you already saw in your own stack.

Defined in
XML 1.0 §1
Category
Parsing and processing
Also written
XML processor

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.

  • The parser stops at the first fatal error and reports it, rather than recovering.

    document.xml
    <a><b></a>
    <c>this is never reached</c>

    What the engine returns

    Opening and ending tag mismatch: b line 1 and a (line 1)
  • And when a document is well-formed it says nothing at all.

    document.xml
    <a><b/></a>

    What the engine returns

    Well-formed.

What catches people out

  • Permissive parsers exist and will accept documents libxml2 rejects. That makes them useful for recovery and dangerous for interchange.
  • The line number in an error message is where the parser gave up, which is often not where the mistake is.
  • A parser is not a validator. Well-formedness is all you get unless a schema is supplied.

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.