使用XSL將XML文檔中的CDATA注釋輸出為HTML文本
1. test.xml
<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet href="test.xsl" type="text/xsl"?>
<entry>
<title>entry with images</title>
<date>August 09, 2003</date>
<author>Kevin</author>
<idnum>000033</idnum>
<permalink>http://alazanto.org/xml/archives/000033.xml</permalink>
<body xmlns:html="http://www.w3.org/1999/xhtml"><![CDATA[]]></more>
<comment-link>http://alazanto.org/xml/archives/000033_comments.xml</comment-link>
<comment-count>6</comment-count>
</entry>
2. test.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/entry">
<html>
<head>
</head>
<body>
<xsl:value-of select="title" />
<xsl:value-of select="body" disable-output-escaping="yes"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
關鍵之外在于使用的命名空間xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 和輸出時加上disable-output-escaping="yes"
相關文章:
1. msxml3.dll 錯誤 800c0019 系統錯誤:-2146697191解決方法2. CSS3實例分享之多重背景的實現(Multiple backgrounds)3. asp中response.write("中文")或者js中文亂碼問題4. 讀大數據量的XML文件的讀取問題5. ASP中格式化時間短日期補0變兩位長日期的方法6. CSS Hack大全-教你如何區分出IE6-IE10、FireFox、Chrome、Opera7. HTML DOM setInterval和clearInterval方法案例詳解8. 詳解盒子端CSS動畫性能提升9. 告別AJAX實現無刷新提交表單10. asp批量添加修改刪除操作示例代碼