SQLSTATE 2200MSeverity lowLab verified

Incident brief

Invalid XML document (DOCUMENT)

XMLPARSE(DOCUMENT ...) requires well-formed XML; mismatched opening and closing tags raise this data exception with a DETAIL pointing at the mismatch.

Reproduced on PostgreSQL 18.4Verified 2026-07-24 (isolated lab, PostgreSQL 18.4)Reviewed by Verified against PostgreSQL 18.4 in an isolated lab environment

In 10 seconds

What
Invalid XML document (DOCUMENT)
What triggers it
Call XMLPARSE(DOCUMENT '<...>') with content whose tags do not match.
The fix
Correct the markup so every opening tag has a matching closing tag.
Proof
Reproduced on PostgreSQL 18.4 → A single SELECT reproduces SQLSTATE 2200M; the mismatched tags are rejected and the DETAIL names them.

The fix

What to do right now

The immediate, application-level response to this error.

  • Correct the markup so every opening tag has a matching closing tag.
  • Validate or generate XML with a real serializer rather than string concatenation.
Fix — SQL
-- Parse only well-formed XML.
SELECT XMLPARSE(DOCUMENT '<order></order>');

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 18.4
Last verified
2026-07-24 (isolated lab, PostgreSQL 18.4)
Reviewed by
Verified against PostgreSQL 18.4 in an isolated lab environment
Audit status
reviewed