Reference to undeclared entity exception while working with XML Reference to undeclared entity exception while working with XML xml xml

Reference to undeclared entity exception while working with XML


XML, unlike HTML does not define entities (ie named references to UNICODE characters) so α — etc. are not translated to their corresponding character. You must use the numerical value instead. You can only use < and & in XML

If you want to create HTML, use an HtmlDocument instead.


In .Net, you can use the System.Xml.XmlConvert class:

string text = XmlConvert.EncodeName("Hello α");

Alternatively, you can declare the entities locally by putting the declarations between square brackets in a DOCTYPE declaration. Add the following header to your xml:

<!DOCTYPE documentElement[<!ENTITY Alpha "&#913;"><!ENTITY ndash "&#8211;"><!ENTITY mdash "&#8212;">]>

Do a google on "html character entities" for the entity definitions.


Try replacing &Alpha with

  &#913;