title: Get DOMXpath results below previous result in HTML
body: <p>I'm trying to sort through the HTML of an external website and, unfortunately, the site is very poorly organized. The data might look something like this:</p>
  
  <pre><code>&lt;a class="title"&gt;Title One&lt;/a&gt;
  &lt;a class="item"&gt;Item One&lt;/a&gt;
  &lt;a class="item"&gt;Item Two&lt;/a&gt;
  
  &lt;a class="title"&gt;Title Two&lt;/a&gt;
  &lt;a class="item"&gt;Item One&lt;/a&gt;
  &lt;a class="item"&gt;Item Two&lt;/a&gt;    
  </code></pre>
  
  <p>And I'm working with an xpath query like this for the titles:</p>
  
  <pre><code>$titles = $x-&gt;evaluate('//a[@class="title"]');
  </code></pre>
  
  <p>Now, I want to list the titles with the items below them. Unfortunately, none of these elements are conveniently wrapped in a parent div, so I can't just filter through everything in the parent. So, I use a query like this for the items:</p>
  
  <pre><code>$titles = $x-&gt;evaluate('//a[@class="item"]');
  </code></pre>
  
  <p>Ideally, what I'd like to do is ONLY check for results below the current title element. So, if I'm looping through and hit "title one", I want to only check the "item" results that appear between title one and title two. Is there any way to do this?</p>
  
  <p>Modifying the HTML is not an option here. I know this question is a little ridiculous and my explanation might be horrible, but if there's a solution, it would really help me!</p>
  
  <p>Thanks everyone.</p>