使用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. 將properties文件的配置設(shè)置為整個(gè)Web應(yīng)用的全局變量實(shí)現(xiàn)方法2. docker compose idea CreateProcess error=2 系統(tǒng)找不到指定的文件的問(wèn)題3. 在Vue 中獲取下拉框的文本及選項(xiàng)值操作4. JS中的常見數(shù)組遍歷案例詳解(forEach, map, filter, sort, reduce, every)5. Python語(yǔ)言規(guī)范之Pylint的詳細(xì)用法6. python爬蟲利用代理池更換IP的方法步驟7. Vue+express+Socket實(shí)現(xiàn)聊天功能8. python中pandas.read_csv()函數(shù)的深入講解9. SpringBoot集成SSM、Dubbo、Redis、JSP的案例小結(jié)及思路講解10. JS算法題解旋轉(zhuǎn)數(shù)組方法示例
