XML error reference · XV021

Undefined entity

A reference names an entity that was never declared.

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 / xmllintEntity 'nbsp' not defined
Firefox DOMParserXML Parsing Error: undefined entity
.NET XmlExceptionReference to undeclared entity 'nbsp'.

What causes it

XML predefines only five entities. Everything else, including all the HTML named entities such as ` `, `©` and `—`, must be declared in a DTD before use. XML inherits none of HTML's entity set, which surprises people moving markup from a web page into a feed or a config file.

See it happen

Triggers the error
<p>Price:&nbsp;10&euro;</p>
Corrected
<p>Price:&#160;10&#8364;</p>

How to fix it

Use a numeric character reference instead: `&#160;` for a non-breaking space, `&#169;` for the copyright sign. Numeric references always work with no declaration. Alternatively declare the entity in an internal DTD subset, or simply insert the character literally in a UTF-8 document.

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