title: Getting nth Element from last in a xml in Sql Server
body: <p>Please consider this XML:</p>
  
  <pre><code>&lt;Employees&gt;
      &lt;Person&gt;
          &lt;ID&gt;1000&lt;/ID&gt;
          &lt;Name&gt;Nima&lt;/Name&gt;
          &lt;LName&gt;Agha&lt;/LName&gt;
      &lt;/Person&gt;
      &lt;Person&gt;
          &lt;ID&gt;1001&lt;/ID&gt;
          &lt;Name&gt;Ligha&lt;/Name&gt;
          &lt;LName&gt;Ligha&lt;/LName&gt;
      &lt;/Person&gt;
      &lt;Person&gt;
          &lt;ID&gt;1002&lt;/ID&gt;
          &lt;Name&gt;Jigha&lt;/Name&gt;
          &lt;LName&gt;Jigha&lt;/LName&gt;
      &lt;/Person&gt;
      &lt;Person&gt;
          &lt;ID&gt;1003&lt;/ID&gt;
          &lt;Name&gt;Aba&lt;/Name&gt;
          &lt;LName&gt;Aba&lt;/LName&gt;
      &lt;/Person&gt;
  &lt;/Employees&gt;
  </code></pre>
  
  <p>I want to write a function that gets a number, and then I get nth <code>Person</code> element, and <code>Name</code>. For example if 0 pass to my function I return <code>Aba</code>, if 1 pass to my function I return <code>Jigha</code>.</p>