title: System.Xml.XmlException: An error occurred while parsing EntityName
body: <p>I am attempting to transform some XML [returned by a sql query e.g. SELECT ... FOR XML  RAW('EmailData'),ROOT('Emails'),type] but for whatever reason just this row is giving me problems:</p>
  
  <pre><code>&lt;Emails&gt;
    &lt;EmailData ID="370" C_ID="93" Co_ID="019" MemberName="Twin Cities Orthopedics – Savage" Commit_Program_ID="92" SubmittedBy="9175" AccountExecInfo="Jessica Cooley, jcooley@cc.com" PortfolioExecInfo="Seth Bull, 000.581.5006, sbulling@CCDD.com" SupplierRepInfo="Matt Matts, 000.000.4236 Ext-37, Matt.Matts@ker.com" MemberInfoLink="https://nf.CCDD.com/asp/memberinfo.asp?memid=7893&amp;amp;co=019" DocumentLink="https://nf.CCDD.com/asp/maintanance.asp?doc_id=630" TermsAndCondLink="https://nf.CCDD.com/TermsAndConditions.asp?CPID=92" Doc_Source_ID="BTM" SubmittedByInfo="Automated Tier Update" /&gt;
  &lt;/Emails&gt;
  </code></pre>
  
  <p>The cuplrit seems to be MemberName attribute value ... because when I return an empty string instead of the above value I do not get the exception. Do you see any invalid charecters? Is '-' an invalid charecter for xml?</p>
  
  <p>My XSL Transformation code:</p>
  
  <pre><code>public static SqlXml Transform(SqlXml inputDataXML, SqlXml inputTransformXML)
          {
              try
              {
                  MemoryStream memoryXml = new System.IO.MemoryStream();
                  XslCompiledTransform xslt = new XslCompiledTransform();
                  XmlReader output = null;
  
                  xslt.Load(inputTransformXML.CreateReader());
  
                  // Output the newly constructed XML
                  XmlTextWriter outputWriter = new XmlTextWriter(memoryXml, System.Text.Encoding.Default);
                  xslt.Transform(inputDataXML.CreateReader(), null, outputWriter, null);
                  memoryXml.Seek(0, System.IO.SeekOrigin.Begin);
                  output = new XmlTextReader(memoryXml);
  
                  return new SqlXml(output);
              }
              catch(Exception ex)
              {
                  byte[] byteArray = Encoding.ASCII.GetBytes( "&lt;error&gt;" + ex.ToString() + "&lt;/error&gt;");
                      MemoryStream stream = new MemoryStream( byteArray );
                      XmlReader reader = new XmlTextReader(stream);
                  SqlXml x = new SqlXml(reader);
  
                  return x;
              }
          }
  </code></pre>