我有HTML以下塊:如何在使用ColdFusion函數XMLFormat()時轉義HTML字符實體?
<p>The quick brown fox jumps over the lazy dog — The quick brown fox jumps over the lazy dog.</p>
<p>The quick brown fox jumps over the lazy dog — The quick brown fox jumps over the lazy dog.
<br>The quick brown fox jumps over the lazy dog — The quick brown fox jumps over the lazy dog.
這不是有效的XHTML。但是,我需要將此HTML包含在XML文檔中。我試圖使用XMLFormat()
爲了將<
轉換爲<
和>
轉換爲>
,這很好。不幸的是,它也將—
轉換爲&mdash;
,這是無效的,並在CFXML標記中引發異常。
<cfxml variable="myXML">
<content>#XMLFormat(myHTML)#</content>
</cfxml>
我該如何解決這個問題?
數據庫中存儲的HTML塊是否與XHTML兼容? – AnthonyWJones 2010-02-04 16:12:30
不,HTML內容無效XHTML – 2010-02-05 04:26:40