使用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" 和輸出時加上disable-output-escaping="yes"
相關(guān)文章:
1. python讓函數(shù)不返回結(jié)果的方法2. python實現(xiàn)讀取類別頻數(shù)數(shù)據(jù)畫水平條形圖案例3. chat.asp聊天程序的編寫方法4. JSP之表單提交get和post的區(qū)別詳解及實例5. 深入了解JAVA 軟引用6. 詳解JAVA 強引用7. Python TestSuite生成測試報告過程解析8. 解決AJAX返回狀態(tài)200沒有調(diào)用success的問題9. 低版本IE正常運行HTML5+CSS3網(wǎng)站的3種解決方案10. python之cur.fetchall與cur.fetchone提取數(shù)據(jù)并統(tǒng)計處理操作
