Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Use</strong>:</p> <pre><code>//table//td//text()[normalize-space()] </code></pre> <p>This selects any non-all-whitespace text node that is a descendent of a <code>td</code> that is a descendent of a <code>table</code> element of the XML document.</p> <p><strong>XSLT - based verification</strong>:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="text"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:template match="node()|@*"&gt; &lt;xsl:for-each select="//table//td//text()[normalize-space()]"&gt; &lt;xsl:copy-of select="."/&gt; ============= &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>When this transformation is applied on the provided XML document:</strong></p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt; &lt;div id="somediv1"&gt; &lt;span&gt;blablabla&lt;/span&gt; &lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div id="somediv2"&gt; &lt;span&gt;text2&lt;/span&gt; &lt;/div&gt; &lt;div id="somediv3"&gt; &lt;span&gt;text3&lt;/span&gt; &lt;/div&gt; &lt;span&gt;text4&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p><strong>the XPath expression is evaluated and all selected text nodes are copied to the output, using a visually distinctive delimiter string</strong>:</p> <pre><code>blablabla ============= text2 ============= text3 ============= text4 ============= </code></pre> <p><strong>Update</strong>:</p> <p>In case the source XML document is in a default namespace, the above XPath expression should be changed to account for this fact:</p> <pre><code>//x:table//x:td//text()[normalize-space() </code></pre> <p>where the prefix <code>"x"</code> is bound to the default namespace of the source XML document.</p> <p><strong>Here is a complete example</strong>, XSLT - based:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="http://www.w3.org/1999/xhtml"&gt; &lt;xsl:output method="text"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:template match="node()|@*"&gt; &lt;xsl:for-each select="//x:table//x:td//text()[normalize-space()]"&gt; &lt;xsl:copy-of select="."/&gt; ============= &lt;/xsl:for-each&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>When this transformation is applied on the following XML document</strong> (the provided one, but put in a default (the XHTML) namespace:</p> <pre><code>&lt;table xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;tr&gt; &lt;td&gt; &lt;div id="somediv1"&gt; &lt;span&gt;blablabla&lt;/span&gt; &lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div id="somediv2"&gt; &lt;span&gt;text2&lt;/span&gt; &lt;/div&gt; &lt;div id="somediv3"&gt; &lt;span&gt;text3&lt;/span&gt; &lt;/div&gt; &lt;span&gt;text4&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p><strong>again the same correct result is produced</strong>:</p> <pre><code>blablabla ============= text2 ============= text3 ============= text4 ============= </code></pre>
 

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