title: How to count preceding sibling count until certain condition is fulfilled?
body: <p>I have following XML .. I want to get the count of 'step' nodes from current 'step' node to the preceding step which has node event with value 'DoubleClick'.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;gps&gt; 
    &lt;step&gt;
      &lt;event&gt;DoubleClick&lt;/event&gt;
    &lt;/step&gt;    
    &lt;step&gt;
      &lt;event&gt;click&lt;/event&gt;
    &lt;/step&gt;
    &lt;step&gt;
      &lt;event&gt;click&lt;/event&gt;
    &lt;/step&gt;  
    &lt;step&gt;
      &lt;event&gt;click&lt;/event&gt;
    &lt;/step&gt;
    &lt;step&gt;
      &lt;event&gt;DoubleClick&lt;/event&gt;
    &lt;/step&gt;    
    &lt;step&gt;
      &lt;event&gt;click&lt;/event&gt;
    &lt;/step&gt;      
    &lt;step&gt;
      &lt;event&gt;click&lt;/event&gt;
    &lt;/step&gt;
    &lt;step&gt;
      &lt;event&gt;click&lt;/event&gt;
    &lt;/step&gt;
    &lt;step&gt;
      &lt;event&gt;DoubleClick&lt;/event&gt;
    &lt;/step&gt;  
  &lt;/gps&gt;</code></pre>
  </div>
  </div>
  </p>