title: XPath - All following siblings except first specific elements
body: <p>Let's say I'm querying an xhtml document, and I want to query all of the siblings following a table with <code>id='target'</code>. Also, I neither want the first <code>&lt;table&gt;</code> sibling nor the first <code>&lt;ol&gt;</code> sibling of this particular element. Here's the best I could come up with:</p>
  
  <pre><code>//table[@id='target']/following-sibling::*[not(self::table[1]) and not(self::ol[1])]
  </code></pre>
  
  <p>However, this isn't returning any results when it should. Obviously I'm not understanding some of the syntax for this (I couldn't find a good source of information). I would certainly appreciate it if someone more experienced with XPath syntax could give me a hand. Also, for purely academic purposes, I'd be curious what the above is actually doing.</p>
  
  <p>UPDATE:<br>
  See LarsH's answer for the explanation of why my XPath wasn't working, and see Dimitre's answer for the accepted solution.</p>