title: How to find all immediately adjacent siblings with XPath
body: <p>I want to find all the immediately adjacent siblings of a node using a single XPath expression, if at all possible. Given the input</p>
  
  
  
  <pre class="lang-xml prettyprint-override"><code>&lt;a id="1"/&gt;
  &lt;start/&gt;
  &lt;a id="2"/&gt;
  &lt;a id="3"/&gt;
  &lt;b/&gt;
  &lt;a id="4"/&gt;
  </code></pre>
  
  <p>and an XPath expression similar to <code>//start/following-sibling::a</code>, I want to select <strong>a[2]</strong>, and <strong>a[3]</strong>, but not <strong>a[4]</strong>. Also, if there are any intervening elements between <strong>start</strong> and <strong>a[2]</strong>, nothing should be selected.</p>