把 CDATA 中的内容(有可能是不规范的Html代码)以Html方式展现出来。
程序员文章站
2023-12-20 10:51:52
前不久我写过 xml+xsl 与 html 的结合 文章,之后有人问我如何把 cdata 中的内容以h...
前不久我写过 xml+xsl 与 html 的结合 文章,之后有人问我如何把 cdata 中的内容以html方式展现出来(尤其是用户写的html不规范)。本来想写个范例,后来到google上一查,发现已经有人写了。就在:http://java.blogger.cn/wuyu/posts/1460.aspx
注意:xsl的disable-output-escaping="yes"
其核心就是利用 disable-output-escaping="yes"
msdn 上对它的描述如下:
disable-output-escaping
default is "no". if the value is "yes", a text node generated by instantiating the element will be output without any escaping. for example, the following generates the single character "<".
<
note?? disable-output-escaping="yes" can be used to generate non-well-formed documents, and thus should be used with caution, because non-well-formed output may generate errors in certain circumstances. for example, transformnodetoobject to an xml document requires that the result be well-formed and thus may not complete ifdisable-output-escaping has affected the well-formedness of the document. consider disable-output-escaping="yes" an advanced feature to be used only when the potential dangers are understood.
注意:xsl的disable-output-escaping="yes"
其核心就是利用 disable-output-escaping="yes"
msdn 上对它的描述如下:
disable-output-escaping
default is "no". if the value is "yes", a text node generated by instantiating the element will be output without any escaping. for example, the following generates the single character "<".
<
note?? disable-output-escaping="yes" can be used to generate non-well-formed documents, and thus should be used with caution, because non-well-formed output may generate errors in certain circumstances. for example, transformnodetoobject to an xml document requires that the result be well-formed and thus may not complete ifdisable-output-escaping has affected the well-formedness of the document. consider disable-output-escaping="yes" an advanced feature to be used only when the potential dangers are understood.