title: return xml from document with highest integer in one element
body: <p>I have a rather long XML document with subsections under elements called <code>&lt;Pages&gt;</code>. Each of these pages contains an element called <code>&lt;NumberOfEntries&gt;</code> with an integer value. </p>
  
  <p>I am trying to show the part of the XML from the <code>&lt;Page&gt;</code> which has the highest number of entries. </p>
  
  <p>I have looked at the <code>fn:max</code> function, but it's not working for me ... </p>
  
  <p>This is what I have tried - </p>
  
  <pre><code>for $x in /Document
  where $x fn:max(//NumberOfEntries)
  return $x//Page::node()
  </code></pre>
  
  <p>EDIT </p>
  
  <p>I just worked out this one but it's returning all the pages - not just the one with the highest number of entries - any suggestions? </p>
  
  <pre><code>for $x in /Document
  where max($x//NumberOfEntries)
  return ($x//Page)
  </code></pre>