title: How to prevent Xpath recursion
body: <p>Given I have this (unknown) document structure, how do I write xpath to select div1 and div2, i.e. all divs, but not recursivelly (no divs, contained anywhere within another divs)?</p>
  
  <p>I couldn't find any documentation that would point me in this direction, all I could manage is to select ALL divs, i.e. div1, div2 and div3 (with <code>//div</code> expression), but I want to exclude div2 here as it is the descendant div of another one.</p>
  
  <p>(I need a generic solution to select tags not recursivelly, the ids here are for explanatory purposes only.)</p>
  
  <pre><code>  ...some unknown structure with no divs...
    &lt;div id="1"&gt;
      ...some unknown structure with no divs...
      &lt;div id="2"&gt;&lt;/div&gt;
      ...some unknown structure with no divs...
    &lt;/div&gt;
    ...some unknown structure with no divs...
    &lt;div id="3"&gt;&lt;/div&gt;
    ...some unknown structure with no divs...
  </code></pre>