I am trying to set the innerxml of a xmldoc but get the exception: Reference to undeclared entity
XmlDocument xmldoc = new XmlDocument();
string text = "Hello, I am text α – —"
xmldoc.InnerXml = "<p>" + text + "</p>";
This throws the exception:
Reference to undeclared entity 'alpha'. Line 2, position 2..
How would I go about solving this problem?
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.