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.
| Parser | Message |
|---|---|
| libxml2 / xmllint | Entity 'nbsp' not defined |
| Firefox DOMParser | XML Parsing Error: undefined entity |
| .NET XmlException | Reference 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
<p>Price: 10€</p><p>Price: 10€</p>How to fix it
Use a numeric character reference instead: ` ` for a non-breaking space, `©` 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.
Everything runs in this tab. Nothing you paste is uploaded, logged or sent anywhere. Open your network panel and check.