title: XPath: how to select following siblings until a certain sibling
body: <p>For the example HTML below, an XPath query that returns the siblings of the "a" elements with class='A' that have class='B' can be written as: <code>//a[@class='A']/following-sibling::a[@class='B']</code>. This query outputs 4 <code>&lt;a class="B"/&gt;</code> elements. </p>
  
  <p>However, I would only like the <code>&lt;a class="B"/&gt;</code> elements that follow the current <code>&lt;a class="A"/&gt;</code> element, and no others that follow other <code>&lt;a class="B"/&gt;</code> elements/nodes. In other words, I only want the following <code>&lt;a class="B"/&gt;</code> sibling elements until the next <code>&lt;a class="B"/&gt;</code> element shows up.</p>
  
  <p>Example HTML:</p>
  
  <pre><code>&lt;a class='A' /&gt;
  &lt;a class='B' /&gt;
  &lt;a class='A' /&gt;
  &lt;a class='B' /&gt;
  &lt;a class='B' /&gt;
  &lt;a class='B' /&gt;
  </code></pre>
  
  <p>Any ideas on how to limit my current XPath query to just those siblings would be much appreciated :)</p>