把 CDATA 中的內容(有可能是不規範的Html代碼)以Html方式展現出來。_經驗交流

來源:互聯網
上載者:User
前不久我寫過 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.
  • 相關文章

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.