XML error reference · XV023

Illegal character in document

A raw control character appears in the document, which XML 1.0 does not permit.

What your parser calls it

The same problem, reported differently by each parser. If you arrived here from one of these strings, you are in the right place.

ParserMessage
libxml2 / xmllintPCDATA invalid Char value 12
Python ElementTreenot well-formed (invalid token)

What causes it

The same restriction as for character references applies to literal bytes: a raw form feed, vertical tab, NUL or escape character is not valid XML 1.0 content anywhere, including inside CDATA sections. These usually arrive from legacy mainframe exports, terminal output captured with ANSI colour codes, or copying out of a PDF.

See it happen

Triggers the error
<log>starteddone</log>
Corrected
<log>started done</log>

How to fix it

Filter the input for characters outside the allowed set before serialising. Most XML libraries do not do this for you. They will happily write a document they cannot read back.

Fix your own document

Paste your own document below. Press Sample if you want the broken example above loaded instead. Nothing you paste leaves this tab.

XML Validator

Well-formedness and schema validation. Nothing is uploaded.

Input
WaitingPaste a document to check it. Validation runs as you type.

Everything runs in this tab. Nothing you paste is uploaded, logged or sent anywhere. Open your network panel and check.

Tools that catch this

Background reading

Errors this fixes

Every XML error, explained