xsl-list
[Top] [All Lists]

Re: Deleting textnode

2004-04-23 02:36:18
Hi Animesh,

I want to delete a text node.

Suppose the XML format is something like:
<tr>
Google search:
<a>English</a>
<a>English</a>
<a>English</a>
</td>

and I want to delete "Gogole Search" text node.

Start off with an identity transformation:

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

Then add a template that does nothing with text node children of <td>
elements:

<xsl:template match="td/text()" />

Alternatively, add a template that only applies templates to the
element children of the <td> element, rather than to all its child
nodes:

<xsl:template match="td">
  <xsl:copy>
    <xsl:apply-templates select="@*|*" />
  </xsl:copy>
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



<Prev in Thread] Current Thread [Next in Thread>