title: Reference to undeclared entity exception while working with XML
body: <p>I am trying to set the innerxml of a xmldoc but get the exception: Reference to undeclared entity</p>
  
  <pre><code>XmlDocument xmldoc = new XmlDocument();
  string text = "Hello, I am text &amp;alpha; &amp;nbsp; &amp;ndash; &amp;mdash;"
  xmldoc.InnerXml = "&lt;p&gt;" + text + "&lt;/p&gt;";
  </code></pre>
  
  <p>This throws the exception: </p>
  
  <blockquote>
    <p>Reference to undeclared entity 'alpha'. Line 2, position 2.. </p>
  </blockquote>
  
  <p>How would I go about solving this problem?</p>