title: How can I escape HTML character entities when using ColdFusion function XMLFormat()?
body: <p>I have the following block of HTML:</p>
  
  <pre><code>&lt;p&gt;The quick brown fox jumps over the lazy dog &amp;mdash; The quick brown fox jumps over the lazy dog.&lt;/p&gt;
  &lt;p&gt;The quick brown fox jumps over the lazy dog &amp;mdash; The quick brown fox jumps over the lazy dog.
  &lt;br&gt;The quick brown fox jumps over the lazy dog &amp;mdash; The quick brown fox jumps over the lazy dog.
  </code></pre>
  
  <p>It is NOT valid XHTML. However, I need to include this HTML in an XML document. I tried using <code>XMLFormat()</code> in order to convert the <code>&lt;</code> to <code>&amp;lt;</code> and the <code>&gt;</code> to <code>&amp;gt;</code>, which works great. Unfortunately, it also converts <code>&amp;mdash;</code> to <code>&amp;amp;mdash;</code>, which is not valid and throws an exception in the CFXML tag.</p>
  
  <pre><code>&lt;cfxml variable="myXML"&gt;
      &lt;content&gt;#XMLFormat(myHTML)#&lt;/content&gt;
  &lt;/cfxml&gt;
  </code></pre>
  
  <p>How can I workaround this?</p>