gpt4 book ai didi

xslt - 使用 XSLT 取消注释 XML 内容

转载 作者:行者123 更新时间:2023-12-02 11:30:52 26 4
gpt4 key购买 nike

我在 XML 和 XSLT 方面遇到问题。我有一个带有一些注释的 XML 文件,我想取消它的注释。

例如:

<my-app>
<name>
</name>
<!-- <class>
<line></line>
</class>-->
</my-app>

我想取消注释此注释标签。

最佳答案

<!-- 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>

请注意,disable-output-escaping="yes" 意味着注释内容应该格式正确。

关于xslt - 使用 XSLT 取消注释 XML 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2020256/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com