title: XPath expression to select self, preceding and following nodes
body: <p>I'd like to select the following HTML in a document, based on the content of TARGET. I.e. if TARGET matches, select everything. However, I'm not sure where to go after: <code>id('page')/x:div/span/a='TARGET'</code> – How to use parent, child, and sibling expressions to get the containing <code>div</code>, the <code>a</code> preceding that <code>div</code>, and the two <code>br</code> tags following the <code>div</code></p>
  
  <pre><code>&lt;a&gt;&lt;/a&gt;
  &lt;div&gt;
      &lt;br /&gt;
      &lt;span&gt;
          &lt;a&gt;TARGET&lt;/a&gt;
          &lt;a&gt;&lt;/a&gt;
          &lt;span&gt;
              &lt;span&gt;
                  &lt;a&gt;&lt;/a&gt;
              &lt;/span&gt;
              &lt;a&gt;&lt;/a&gt;
              &lt;span&gt;&lt;/span&gt;
          &lt;/span&gt;
          &lt;span&gt;
              &lt;a&gt;&lt;/a&gt;
          &lt;/span&gt;
      &lt;/span&gt;
  &lt;/div&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  </code></pre>