title: counting number of elements from XML using xpath
body: <p>I've used this excellent forum to teach myself some basic xpath to query an .XML file. I've got a sample of my XML file here, and I'm trying to import the [X,Y] coordinates of 3 objects in the XML file using Matlab:</p>
  
  <pre><code>&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
  &lt;dict&gt;
      &lt;key&gt;ROI array&lt;/key&gt;
      &lt;array&gt;
          &lt;dict&gt;
              &lt;key&gt;Comments&lt;/key&gt;
              &lt;string&gt;&lt;/string&gt;
              &lt;key&gt;Name&lt;/key&gt;
              &lt;string&gt;Unnamed&lt;/string&gt;
              &lt;key&gt;ROIPoints&lt;/key&gt;
              &lt;array&gt;
                  &lt;string&gt;{129.24051549947484, 263.66036033996352}&lt;/string&gt;
                  &lt;string&gt;{114.61421850240453, 278.56760216125258}&lt;/string&gt;
                  &lt;string&gt;{123.11826208150609, 289.73859978088149}&lt;/string&gt;
                              &lt;string&gt;{125.11111111111111, 295.77777777777777}&lt;/string&gt;
              &lt;/array&gt;
              &lt;key&gt;Slice&lt;/key&gt;
              &lt;integer&gt;58&lt;/integer&gt;
          &lt;/dict&gt;
          &lt;dict&gt;
              &lt;key&gt;Comments&lt;/key&gt;
              &lt;string&gt;&lt;/string&gt;
              &lt;key&gt;Name&lt;/key&gt;
              &lt;string&gt;Unnamed&lt;/string&gt;
              &lt;key&gt;ROIPoints&lt;/key&gt;
              &lt;array&gt;
                  &lt;string&gt;{127.09352448499425, 261.31629753478774}&lt;/string&gt;
                  &lt;string&gt;{112.50917389905675, 277.25509453185805}&lt;/string&gt;
                  &lt;string&gt;{126.061969309213, 291.36980247863539}&lt;/string&gt;
                  &lt;string&gt;{141.48499634778722, 292.16234398254164}&lt;/string&gt;
                  &lt;string&gt;{149.71229126966222, 277.81281090148696}&lt;/string&gt;
              &lt;/array&gt;
              &lt;key&gt;Slice&lt;/key&gt;
              &lt;integer&gt;59&lt;/integer&gt;
          &lt;/dict&gt;
          &lt;dict&gt;
              &lt;key&gt;Comments&lt;/key&gt;
              &lt;string&gt;&lt;/string&gt;
              &lt;key&gt;Name&lt;/key&gt;
              &lt;string&gt;Unnamed&lt;/string&gt;
              &lt;key&gt;ROIPoints&lt;/key&gt;
              &lt;array&gt;
                  &lt;string&gt;{134.32833430087788, 258.21743274101027}&lt;/string&gt;
                  &lt;string&gt;{117.0812182120107, 266.44891620048293}&lt;/string&gt;
                  &lt;string&gt;{114.41427180087788, 292.20427203544386}&lt;/string&gt;
                  &lt;string&gt;{128.80573603427632, 299.11905932792433}&lt;/string&gt;
                  &lt;string&gt;{147.92307612216695, 299.11905932792433}&lt;/string&gt;
                  &lt;string&gt;{152.73700281894429, 285.80526996024855}&lt;/string&gt;
                  &lt;string&gt;{154.32626673495992, 268.51202655204543}&lt;/string&gt;
              &lt;/array&gt;
              &lt;key&gt;Slice&lt;/key&gt;
              &lt;integer&gt;60&lt;/integer&gt;
          &lt;/dict&gt;
          &lt;/array&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>I've managed to export all of the coordinates using this Matlab code:</p>
  
  <pre><code>expression_2 = xpath.compile('plist/dict/array/dict/array/string');
  nodeList_2 = expression_2.evaluate(docNode, XPathConstants.NODESET);
  for i = 1:nodeList_2.getLength
      node = nodeList_2.item(i-1);
      coordinate_node{i} = char(node.getFirstChild.getNodeValue);
  end
  </code></pre>
  
  <p>Does anyone know of an xpath query whereby I could count the NUMBER of [X,Y] coordinates in each object? I.e. something that returns 4 coordinates for the first object, 5 coordinates in the second and 7 coordinates in the 3rd?</p>
  
  <p>Thanks,
  Jim</p>