相关疑难解决方法(0)

使用ColdFusion函数XMLFormat()时,如何转义HTML字符实体?

我有以下HTML块:

<p>The quick brown fox jumps over the lazy dog &mdash; The quick brown fox jumps over the lazy dog.</p>
<p>The quick brown fox jumps over the lazy dog &mdash; The quick brown fox jumps over the lazy dog.
<br>The quick brown fox jumps over the lazy dog &mdash; The quick brown fox jumps over the lazy dog.
Run Code Online (Sandbox Code Playgroud)

它不是有效的XHTML.但是,我需要将此HTML包含在XML文档中.我尝试使用XMLFormat()以转换为<to &lt;>to &gt;,这很有效.不幸的是,它也转换&mdash;&amp;mdash;无效,并在CFXML标记中抛出异常.

<cfxml variable="myXML">
    <content>#XMLFormat(myHTML)#</content>
</cfxml>
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

html xml coldfusion character-encoding

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

character-encoding ×1

coldfusion ×1

html ×1

xml ×1