PCDATA invalid Char value

A control character that XML 1.0 does not allow.

The message, as the validator reports it
PCDATA invalid Char value 1

Why it happens

  • Characters below U+0020 other than tab, newline and carriage return, often from a database field, a log line or a binary value written into XML.
  • The value in the message is the character code: 1 is U+0001, 12 a form feed, 0 a NUL byte.

How to fix it

Remove the characters or replace them with a space when the XML is produced. They cannot be escaped:  is not allowed in XML 1.0 either. Binary data belongs in Base64.

Example

Reports the error
<note>a\x01b</note>
Fixed
<note>a b</note>