Undefined XML Entity – Fix Entity Not Defined Errors

Local only

An undefined entity error means the parser encountered a named entity reference that XML does not know in the current document.

19 chars · 1 line

Waiting for input

Loading XML parser…

XML entity troubleshooting

How to fix an undefined entity in XML

The preloaded XML uses  , which is familiar from HTML but is not one of XML's five predefined named entities. XML parsers reject the reference unless the entity is explicitly declared, so portable XML usually uses a numeric character reference instead. This tool is free to use. No account or payment is required.

Last updated

What you can do here

  • XML well-formedness validation
  • Broken XML example preloaded
  • Corrected XML comparison
  • .xml file import
  • Browser parser feedback
  • Browser-local processing

Steps

  1. Validate the exact XML and identify the entity name reported by the parser.
  2. Use only XML predefined named entities unless the document intentionally declares additional entities.
  3. Replace HTML-only names such as   with a numeric character reference such as   and validate again.

HTML entity names are not automatically XML entities

XML predefines only amp, lt, gt, apos, and quot. Names commonly accepted by HTML, including nbsp, copy, or mdash, are not automatically available in standalone XML documents.

Prefer numeric references when portability matters

A numeric reference such as   does not depend on a custom DTD entity declaration, which makes the XML easier to exchange across generic parsers and services.

Undefined XML entity example

Replace the HTML-only nbsp entity with a numeric non-breaking-space reference.

Invalid XML

<root>&nbsp;</root>

Corrected XML

<root>&#160;</root>

Common questions

Frequently asked questions

Is &nbsp; valid XML?

Not by default. XML does not predefine nbsp; use a numeric reference or declare the entity explicitly.

Which named entities are predefined in XML?

XML predefines amp, lt, gt, apos, and quot.

Can a DTD define additional XML entities?

Yes, but consumers must process the relevant declaration. Numeric references are often simpler for portable data XML.

Debugging a specific XML issue? Browse XML troubleshooting.