Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's another option that will remove text from any element with mixed content (both elements and text)...</p> <p><strong>XML Input</strong></p> <pre><code>&lt;root&gt; &lt;tree&gt; &lt;leaf&gt;Hello&lt;/leaf&gt; ignore me &lt;pear&gt;World&lt;/pear&gt; &lt;/tree&gt; &lt;/root&gt; </code></pre> <p><strong>XSLT 1.0</strong></p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output indent="yes"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:template match="@*|node()"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|node()"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="*[* and text()]"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|*"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>XML Output</strong></p> <pre><code>&lt;root&gt; &lt;tree&gt; &lt;leaf&gt;Hello&lt;/leaf&gt; &lt;pear&gt;World&lt;/pear&gt; &lt;/tree&gt; &lt;/root&gt; </code></pre> <p>Also, if the text really is only <code>ignore me</code>, you could do this:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output indent="yes"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:template match="@*|node()"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|node()"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="text()[normalize-space(.)='ignore me']"/&gt; &lt;/xsl:stylesheet&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload