Reputation: 842
How to copy xml document skipping some top level nodes. 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>
Upvotes: 0
Views: 1202
Reputation: 167471
<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>
Upvotes: 3