Erik
Erik

Reputation: 940

How can I strip the link but not the text inside

I have this:

<h1>This <i>is</i> a <a href="#someID">good</a> link</h1>

And I want to strip out ONLY the <a> but not what is IN the <a>, and NOT the italic, so I get:

This <i>is</i> a good link

How can I do that in XSLT 2.0?

Upvotes: 0

Views: 17

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167726

Use

<xsl:template match="a">
  <xsl:apply-templates/>
</xsl:template>

for the a element, together with the identity transformation template

<xsl:template match="@* | node()">
  <xsl:copy>
    <xsl:apply-templates select="@* , node()"/>
  </xsl:copy>
</xsl:template>

Upvotes: 2

Related Questions