title: How to get the nearest ancestor or child of an ancestor with xpath
body: <p>Look at <code>&lt;bookmark/&gt;</code>. The desired output I want is the id with value <code>5</code></p>
  
  <p><code>&lt;xsl:value-of select="//bookmark/ancestor::*[@id][1]/@id"/&gt;</code> only gives me <code>4</code></p>
  
  
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;content&gt;
     &lt;section id="1"&gt;
          &lt;section id="2"/&gt;
          &lt;section id="3"/&gt;
          &lt;section id="9"/&gt;
      &lt;/section&gt;
      &lt;section id="4"&gt;
          &lt;section&gt;
              &lt;section id="10"/&gt;
              &lt;section id="5"/&gt;
              &lt;section&gt;
                  &lt;bookmark/&gt;
                  &lt;section id="6"&gt;
                      &lt;section id="7"&gt;
                          &lt;section id="8"/&gt;
                      &lt;/section&gt;
                  &lt;/section&gt;
              &lt;/section&gt;
          &lt;/section&gt;
      &lt;/section&gt;
  &lt;/content&gt;
  </code></pre>