Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try the following transforms:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:template match="/"&gt; &lt;html&gt; &lt;body&gt; &lt;h2&gt;Matched Items&lt;/h2&gt; &lt;xsl:apply-templates select= "//item[category/.='/General/']"/&gt; &lt;/body&gt; &lt;/html&gt; &lt;/xsl:template&gt; &lt;xsl:template match="item"&gt; &lt;div class="news-item" width="100%"&gt; &lt;div class="news-item-title" width="100%"&gt; &lt;a href="{linkUrl}" target="_blank"&gt; &lt;xsl:value-of select="title"/&gt; &lt;/a&gt; &lt;/div&gt; &lt;xsl:if test="string-length(imageUrl) &amp;gt; 0"&gt; &lt;div class="news-item-image"&gt; &lt;img src="{imageUrl}" /&gt; &lt;/div&gt; &lt;/xsl:if&gt; &lt;div class="news-item-description"&gt; &lt;xsl:value-of select="description"/&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="clear" /&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>The important part is this XPath, which selects all item nodes that have a category with the given value:</p> <pre><code>//item[category/.='/General/'] </code></pre> <p>Applying the transform to this document:</p> <pre><code>&lt;items&gt; &lt;item&gt; &lt;link&gt;http://www.threelanews.com/articles/?id=50456&lt;/link&gt; &lt;category&gt;/General/&lt;/category&gt; &lt;category&gt;/Technology/&lt;/category&gt; &lt;category&gt;/Technology/Telecommunications/&lt;/category&gt; &lt;category&gt;/Technology/Information Technology/Internet/&lt;/category&gt; &lt;title&gt;Sony debuts handsets at CES&lt;/title&gt; &lt;description&gt;The Xperia S will be available globally from the first quarter of 2012.&amp;#xD;Sony Ericsson will showcase the first handsets from...&lt;/description&gt; &lt;pubDate&gt;Tue, 10 Jan 2012 12:11:01 +0200&lt;/pubDate&gt; &lt;/item&gt; &lt;item&gt; &lt;link&gt;http://www.threelanews.com/articles/?id=50456&lt;/link&gt; &lt;category&gt;/Technology/&lt;/category&gt; &lt;category&gt;/Technology/Telecommunications/&lt;/category&gt; &lt;category&gt;/Technology/Information Technology/Internet/&lt;/category&gt; &lt;title&gt;Sony debuts handsets at CES&lt;/title&gt; &lt;description&gt;The Xperia S will be available globally from the first quarter of 2012.&amp;#xD;Sony Ericsson will showcase the first handsets from...&lt;/description&gt; &lt;pubDate&gt;Tue, 10 Jan 2012 12:11:01 +0200&lt;/pubDate&gt; &lt;/item&gt; &lt;/items&gt; </code></pre> <p>Gives the expected result:</p> <pre><code>&lt;H2&gt;Matched Items&lt;/H2&gt; &lt;DIV class=news-item width="100%"&gt; &lt;DIV class=news-item-title width="100%"&gt;&lt;A href="" target=_blank&gt;Sony debuts handsets at CES&lt;/A&gt;&lt;/DIV&gt; &lt;DIV class=news-item-description&gt;The Xperia S will be available globally from the first quarter of 2012. Sony Ericsson will showcase the first handsets from...&lt;/DIV&gt; &lt;/DIV&gt; &lt;DIV class=clear&gt;&lt;/DIV&gt; </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