XML error · entity
CharRef: invalid decimal value
A numeric character reference was opened with &# and never closed with a semicolon, so the parser read past the digits into text that is not a number.
CharRef: invalid decimal value (line 2)What it means
A numeric reference is & in decimal or & in hexadecimal, and the semicolon is part of the syntax rather than punctuation you can drop. Without it the parser keeps consuming characters as digits until it meets one that is not.
The message says "invalid decimal value" because that is what it was left holding — the digits plus whatever followed them. The defect is the missing terminator, not the number.
What usually causes it
- Writing & or   without the closing semicolon.
- An escaping pass that emitted the reference and a later pass that stripped semicolons.
- Hand-written references copied from documentation that omitted the terminator.
- A truncation that landed mid-reference.
How to fix it
- Close every reference with a semicolon: & and &, never &.
- Prefer writing the character directly — the document is UTF-8, so © and — need no reference at all.
- Escape with a library rather than by hand; the semicolon is the part people forget.
The same error elsewhere
Different parsers, same defect. If you arrived with one of these messages, you are in the right place.
Xerces (Java)
The reference to entity "#38" must end with the ';' delimiter.expat (Python)
not well-formed (invalid token): line 2, column 6.NET System.Xml
An error occurred while parsing EntityName.
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.
<?xml version="1.0"?>
<root>&</root><?xml version="1.0"?>
<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
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.