XML error · entity
CharRef: invalid hexadecimal value
A hexadecimal character reference begins with &#x but the characters before its semicolon are not hexadecimal digits.
CharRef: invalid hexadecimal value (line 1)What it means
After &#x, XML accepts only hexadecimal digits 0–9, A–F and a–f until the required semicolon. Any other character means the parser cannot turn the reference into a Unicode code point.
The message is about syntax before it is about the resulting character. First make the digits valid; a separate invalid-character message may still follow if the resulting code point is forbidden in XML.
What usually causes it
- A reference copied with the literal placeholder &#xZZ; or &#xNN; still in it.
- A decimal value written after the x even though it contains digits outside hexadecimal notation.
- A truncated or templated value that inserted punctuation before the closing semicolon.
- Confusing a Unicode name such as U+00A9 with the digits a character reference expects.
How to fix it
- Use only hexadecimal digits and close the reference with a semicolon: © for ©.
- Remove the x when the number is decimal: © is the same character.
- Prefer writing the Unicode character directly in a UTF-8 document when a reference adds no clarity.
The same error elsewhere
Different parsers, same defect. If you arrived with one of these messages, you are in the right place.
expat (Python)
not well-formed (invalid token): line 1, column 9Xerces (Java)
A hexadecimal representation must immediately follow the &#x in a character reference.
Before and after
Both snippets are re-checked by the test suite against the real parser: the first is confirmed to produce the exact error above, the second to parse cleanly.
<root>&#xZZ;</root><root>©</root>Where this bites most
Other XML errors
- Opening and ending tag mismatch
- Premature end of data in tag
- Extra content at the end of the document
- Unescaped ampersand (EntityRef: expecting ';')
- Entity is not defined
- Start tag expected
- XML declaration allowed only at the start of the document
- Unquoted attribute value (AttValue expected)
- Attribute redefined
- Attributes construct error (unterminated quote)
- Invalid element name
- Document is empty
- Unsupported encoding
- Sequence ']]>' not allowed in content
- Comment not terminated
- Detected an entity reference loop
- PCDATA invalid Char value (control character)
- Unescaped '<' in an attribute value
- Invalid numeric character reference
- Blank needed here
- Malformed declaration expecting version
- Unsupported XML version
- Processing instruction not terminated
- CData section not finished
- Error parsing attribute name
- Double hyphen within comment
- CharRef: invalid decimal value
- standalone accepts only 'yes' or 'no'
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.