user1321466
user1321466

Reputation: 1969

how remove tag (which contains special tag ) via xslt

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

Answers (1)

HorusKol
HorusKol

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

Related Questions