当前位置:首页>网络学院>程序开发>XML教程>文章内容

使用XSL将XML文档中的CDATA注释输出为HTML文本

[ 来源:www.it55.com | 作者: | 时间:2007-07-14 | 收藏 | 推荐 ] 【

示例代码

1.   test.xml sflj www.it55.com kg^&fgd

<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet href="http://edu.iecool.com/show/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[<p><img
  class="archive" align="right" src=""
  alt="photograph of a flower, just for show"/>Mauris felis elit, varius
  quis, pulvinar vel, sodales vehicula, mi. Nunc elementum pharetra elit.
  </p>]]>
 </body>
 <more xmlns:html="http://www.w3.org/1999/xhtml"><![CDATA[]]></more>
 <comment-link>http://alazanto.org/xml/archives/000033_comments.xml</comment-link> vd;k;l www.it55.com rdfg
 <comment-count>6</comment-count>
</entry>

IT资讯之家 www.it55.com

2.  test.xsl 免费资源www.it55.com

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

免费资源www.it55.com

<xsl:template match="/entry">
<html>
<head>
</head>
<body>
<xsl:value-of select="title" />
<xsl:value-of select="body" disable-output-escaping="yes"/>

www.it55.com在线教程

</body>
</html>
</xsl:template>
</xsl:stylesheet> vd;k;l www.it55.com rdfg


关键之外在于使用的命名空间xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 和输出时加上disable-output-escaping="yes"

sflj www.it55.com kg^&fgd

(编辑:IT资讯之家 www.it55.com

返回顶部
 

网友评论

[以下评论为网友观点,不代表本站。请自觉遵守互联网相关政策法规,所有连带责任均有评论者自负。]
[不超过250字]

图片文章