我有XML和XSLT的问题.我有一个带有一些注释的XML文件,我想取消注释.
例如:
<my-app>
<name>
</name>
<!-- <class>
<line></line>
</class>-->
</my-app>
Run Code Online (Sandbox Code Playgroud)
我想取消注释这个注释标签.
Tom*_*lak 11
<!-- the identity template copies everything
(unless more specific templates apply) -->
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
<!-- this template matches comments and uncomments them -->
<xsl:template match="comment()">
<xsl:value-of select="." disable-output-escaping="yes" />
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
请注意,这disable-output-escaping="yes"
意味着评论内容应该是格式良好的.