Reputation: 1969
I have following xml.
<rules>
<rule>
<name>aa</name>
</rule>
<rule>
<name>bb</name>
</rule>
<rule>
<name>cc</name>
</rule>
</rules>
I would like to remove rule which name is 'bb' via xslt. So the output should be -
<rules>
<rule>
<name>aa</name>
</rule>
<rule>
<name>cc</name>
</rule>
</rules>
I have tried this , but it does not work.
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//rules[rule[name[text()='bb']]]">
</xsl:template>
Thanks.
Upvotes: 2
Views: 92
Reputation: 8706
To remove the specific rule element which has a name element, which has the text, all you should need in your match is:
<xsl:template match="rule[name[text()='bb']]">
Upvotes: 3