title: How to get the last element of a sequence in XPath?
body: <p>In Ruby we can access an array with negative numbers like <code>array[-1]</code> to get the last object in the array.  How do I do this using XPath?</p>
  
  <p>I can't do this:</p>
  
  <pre><code>result = node.xpath('.//ROOT/TAG[-1]/KEY_NAME')
  </code></pre>
  
  <p>I found a solution here on Stack Overflow, but that is a query that just changes the upper limit to get elements. This could return one last item or last item and prevous.</p>
  
  <p>What if I want to get only the prevous element like <code>array[-2]</code> in Ruby?</p>