title: XPath to return all elements on the same level
body: <p>I am trying to work out the XPath from <code>&lt;a id='me'&gt;match&lt;/a&gt;</code> that will match elements that are on the same level.  IE. Siblings, Cousins, Second Cousins etc...</p>
  
  <p>Using the following XML, an XPath expression from the first <code>&lt;a id='me'&gt;match&lt;/a&gt;</code> that returns all of the elements on the same level with an id attribute of 'me':-</p>
  
  <pre><code>&lt;alpha&gt;
      &lt;beta&gt;
          &lt;gamma1&gt;
              &lt;a id='me'&gt;match&lt;/a&gt;
              &lt;a id='me'&gt;match me too&lt;/a&gt;
              &lt;b id='me'&gt;no match&lt;/b&gt;
          &lt;/gamma1&gt;
          &lt;gamma2&gt;
              &lt;a id='notme'&gt;no match&lt;/a&gt;
              &lt;a id='me'&gt;match&lt;/a&gt;
              &lt;/b&gt;
          &lt;/gamma2&gt;
      &lt;/beta&gt;
      &lt;delta&gt;
          &lt;epsilon&gt;
              &lt;a id='notme'&gt;no match&lt;/a&gt;
              &lt;a id='me'&gt;match&lt;/a&gt;
              &lt;/b&gt;
              &lt;foo&gt;
                  &lt;a id='me'&gt;no match&lt;/a&gt;
              &lt;/foo&gt;
          &lt;/epsilon&gt;
      &lt;/delta&gt;
      &lt;bar&gt;
        &lt;a id='me'&gt;no match&lt;/a&gt;
      &lt;/bar&gt;
  &lt;/alpha&gt;
  </code></pre>
  
  <p><code>.\..\a[@id='me']</code> would return the two elements in <code>&lt;gamma1&gt;</code> and <code>.\..\..\*\a[@id='me']</code> would return the matching elements in <code>&lt;gamma1&gt;</code> and <code>&lt;gamma2&gt;</code>.  However, I'm trying to do an XPath that will return all the matching elements on the same level within document, irrelevant of their depth.</p>
  
  <p>I could loop in code, going up and down by constructing dynamic xpaths but it wouldn't be very elegant and probably take a long time to run..</p>
  
  <p>Anyone with any ideas?</p>