使用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>
關(guān)鍵之外在于使用的命名空間xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 和輸出時(shí)加上disable-output-escaping="yes"
相關(guān)文章:
1. java實(shí)現(xiàn)圖形化界面計(jì)算器2. Spring-Richclient 0.1.0 發(fā)布3. javascript設(shè)計(jì)模式 ? 建造者模式原理與應(yīng)用實(shí)例分析4. 解決idea中yml文件不識(shí)別的問題5. IntelliJ IDEA設(shè)置條件斷點(diǎn)的方法步驟6. Python使用oslo.vmware管理ESXI虛擬機(jī)的示例參考7. IDEA的Mybatis Generator駝峰配置問題8. IIS Express 取代 ASP.NET Development Server的配置方法9. IntelliJ Idea2017如何修改緩存文件的路徑10. JSP servlet實(shí)現(xiàn)文件上傳下載和刪除
