<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
  <channel>
    <title><![CDATA[Content with Style - Comments on Find your node: Advanced XPATH commands]]></title>
    <link>http://www.contentwithstyle.co.uk/feeds/rss/comments/8</link>
    <description><![CDATA[]]></description>
    <pubDate>Tue, 07 Sep 2010 21:01:56 -0400</pubDate>
    <generator>Zend_Feed</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <item>
      <title><![CDATA[Content with Style - Comment #1 on Find your node: Advanced XPATH commands]]></title>
      <link>http://www.contentwithstyle.co.uk/content/find-your-node-advanced-xpath-commands/#comment-1570</link>
      <guid>http://www.contentwithstyle.co.uk/content/find-your-node-advanced-xpath-commands/#comment-1570</guid>
      <description><![CDATA[A little while ago I was asked to look at some XSLT for someone who had done some changes to a template they didn&#8217;t originally create, but who now couldn&#8217;t figure out what the hell was going on. You know, the usual stuff.]]></description>
      <content:encoded><![CDATA[A little while ago I was asked to look at some XSLT for someone who had done some changes to a template they didn&#8217;t originally create, but who now couldn&#8217;t figure out what the hell was going on. You know, the usual stuff.]]></content:encoded>
      <pubDate>Fri, 22 Sep 2006 04:15:19 -0400</pubDate>
    </item>
    <item>
      <title><![CDATA[Content with Style - Comment #2 on Find your node: Advanced XPATH commands]]></title>
      <link>http://www.contentwithstyle.co.uk/content/find-your-node-advanced-xpath-commands/#comment-1953</link>
      <guid>http://www.contentwithstyle.co.uk/content/find-your-node-advanced-xpath-commands/#comment-1953</guid>
      <description><![CDATA[I&#8217;m having an xpath issue trying to work out how to select nodes where two child nodes are present.<br />
<br />
My XML format is along these lines:<br />
<br />
&lt;categories&gt;<br />
&nbsp;&nbsp; &lt;cat id=&#8221;1&#8221; name=&#8221;Type A&#8221; /&gt;<br />
&nbsp;&nbsp; &lt;cat id=&#8221;2&#8221; name=&#8221;Type B&#8221; /&gt;<br />
&nbsp;&nbsp; &lt;cat id=&#8221;3&#8221; name=&#8221;Type 1&#8221; /&gt;<br />
&nbsp;&nbsp; &lt;cat id=&#8221;4&#8221; name=&#8221;Type 2&#8221; /&gt;<br />
&nbsp;&nbsp; &lt;cat id=&#8221;5&#8221; name=&#8221;Type 3&#8221; /&gt;<br />
&lt;/categories&gt;<br />
<br />
&lt;products&gt;<br />
&nbsp;&nbsp; &lt;product id=&#8221;1&#8221; name=&#8221;Product 1&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;categories&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cat&gt;1&lt;/cat&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cat&gt;3&lt;/cat&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/categories&gt;<br />
&nbsp;&nbsp;&lt;/product&gt;<br />
&nbsp;&nbsp; &lt;product id=&#8221;2&#8221; name=&#8221;Product 2&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;categories&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cat&gt;2&lt;/cat&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cat&gt;3&lt;/cat&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cat&gt;4&lt;/cat&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/categories&gt;<br />
&nbsp;&nbsp; &lt;/product&gt;<br />
&lt;/products&gt;<br />
<br />
Because of the nature of the products they may belong to one or more category, and I need to be able to filter by one or more category, so I&#8217;m trying to do a query along the lines of:<br />
<br />
&#8220;product/categories[cat=3 and cat=2]/../@name&#8221;<br />
<br />
 constructing the cat=X part on the fly<br />
<br />
I did consider comma seperating my cat ids in the product and using contains(), but then I&#8217;d get all the 22 containing 2 type problems<br />
<br />
Any pointers very gratefully received]]></description>
      <content:encoded><![CDATA[I&#8217;m having an xpath issue trying to work out how to select nodes where two child nodes are present.<br />
<br />
My XML format is along these lines:<br />
<br />
&lt;categories&gt;<br />
&nbsp;&nbsp; &lt;cat id=&#8221;1&#8221; name=&#8221;Type A&#8221; /&gt;<br />
&nbsp;&nbsp; &lt;cat id=&#8221;2&#8221; name=&#8221;Type B&#8221; /&gt;<br />
&nbsp;&nbsp; &lt;cat id=&#8221;3&#8221; name=&#8221;Type 1&#8221; /&gt;<br />
&nbsp;&nbsp; &lt;cat id=&#8221;4&#8221; name=&#8221;Type 2&#8221; /&gt;<br />
&nbsp;&nbsp; &lt;cat id=&#8221;5&#8221; name=&#8221;Type 3&#8221; /&gt;<br />
&lt;/categories&gt;<br />
<br />
&lt;products&gt;<br />
&nbsp;&nbsp; &lt;product id=&#8221;1&#8221; name=&#8221;Product 1&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;categories&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cat&gt;1&lt;/cat&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cat&gt;3&lt;/cat&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/categories&gt;<br />
&nbsp;&nbsp;&lt;/product&gt;<br />
&nbsp;&nbsp; &lt;product id=&#8221;2&#8221; name=&#8221;Product 2&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;categories&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cat&gt;2&lt;/cat&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cat&gt;3&lt;/cat&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cat&gt;4&lt;/cat&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/categories&gt;<br />
&nbsp;&nbsp; &lt;/product&gt;<br />
&lt;/products&gt;<br />
<br />
Because of the nature of the products they may belong to one or more category, and I need to be able to filter by one or more category, so I&#8217;m trying to do a query along the lines of:<br />
<br />
&#8220;product/categories[cat=3 and cat=2]/../@name&#8221;<br />
<br />
 constructing the cat=X part on the fly<br />
<br />
I did consider comma seperating my cat ids in the product and using contains(), but then I&#8217;d get all the 22 containing 2 type problems<br />
<br />
Any pointers very gratefully received]]></content:encoded>
      <pubDate>Wed, 31 Jan 2007 07:06:40 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Content with Style - Comment #3 on Find your node: Advanced XPATH commands]]></title>
      <link>http://www.contentwithstyle.co.uk/content/find-your-node-advanced-xpath-commands/#comment-1954</link>
      <guid>http://www.contentwithstyle.co.uk/content/find-your-node-advanced-xpath-commands/#comment-1954</guid>
      <description><![CDATA[Hey there.<br />
Try to use count() and value():
<br />
<br />
<pre><code>
//product/categories[count(cat[text() = '2']) &amp;gt; 0 and count(cat[text() = '3']) &gt; 0]/../@name
</code></pre>
<br/>
<br/>
You can create that in a loop as well :)]]></description>
      <content:encoded><![CDATA[Hey there.<br />
Try to use count() and value():
<br />
<br />
<pre><code>
//product/categories[count(cat[text() = '2']) &amp;gt; 0 and count(cat[text() = '3']) &gt; 0]/../@name
</code></pre>
<br/>
<br/>
You can create that in a loop as well :)]]></content:encoded>
      <pubDate>Sun, 14 Dec 2008 16:45:59 -0500</pubDate>
    </item>
  </channel>
</rss>
