PG
PRO
2200NERRORTier 2 — Caution✅ HIGH confidence

invalid XML content

Category: Data ExceptionVersions: All Postgres versions (XML support must be compiled in)

What this means

SQLSTATE 2200N is raised when XML content (a fragment, not a full document) fails well-formedness checks when parsed with XMLPARSE(CONTENT ...).

Why it happens

  1. 1XML fragment with syntax errors passed to an XML CONTENT context

How to reproduce

Parsing an invalid XML fragment.

trigger — this will ERROR
SELECT XMLPARSE(CONTENT '<a>unclosed');
ERROR: invalid XML content

Fix 1: Fix the XML fragment syntax

When parsing XML content fragments.

fix
SELECT XMLPARSE(CONTENT '<a>closed</a>');

Why this works

Ensure all tags are properly closed and the fragment is well-formed XML.

Sources

📚 Official docs: https://www.postgresql.org/docs/current/errcodes-appendix.html

🔧 Source ref: Class 22 — Data Exception

Confidence assessment

✅ HIGH confidence

Standard SQLSTATE. Stable across versions.

See also

📄 Reference pages

XML FunctionsXMLPARSE
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →