我想用XML构建一个既可以保存文本又可以保存代码的文件,如下所示:
<root>
<item>Use the <code>location.href</code> propriety to change the URL.</item>
<item>Something else.</item>
</root>
我想创建一个XSLT文件,将XML转换为HTML:
<html>
<body>
<ul>
<li>Use the <code>location.href</code> propriety to change the URL.</li>
<li>Something else.</li>
</ul>
</body>
</html>
我尝试使用此XSLT代码,但它输出的HTML忽略了
<code>
标签它的内容仍然可见,但标签本身(及其格式)却无处可寻。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<ul>
<xsl:for-each select="root/item">
<li><xsl:value-of select="." /></li>
</xsl:for-each>
</ul>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我还尝试在XML文件中替换
<代码(>);
具有
<code>
,但结果是一样的。
请告诉我怎么做。