[英]Copy xml with xslt skipping top level nodes
How to copy xml document skipping some top level nodes. 如何跳过一些顶级节点来复制xml文档。 For example: 例如:
Input: 输入:
<root>
<subroot>
<nodeX id="1">
<!-- inner structure -->
</nodeX>
<nodeX id="2">
<!-- inner structure -->
</nodeX>
<!-- other nodes -->
</subroot>
<root>
Output: 输出:
<nodeX id="1">
<!-- inner structure -->
</nodeX>
<nodeX id="2">
<!-- inner structure -->
</nodeX>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="root | subroot">
<xsl:apply-templates/>
</xsl:template>
should. 应该。 If you want or need something more generic then make the second template 如果您想要或需要更通用的东西,请制作第二个模板
<xsl:template match="/* | /*/*">
<xsl:apply-templates/>
</xsl:template>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.