title: jquery how to access the an xml node by index?
body: <p>say I've an xml returned from server like this:</p>
  
  <pre><code>&lt;persons&gt;
          &lt;person&gt;
                 &lt;firstname&gt;Jon&lt;/firstname&gt;
          &lt;/person&gt;
          &lt;person&gt;
                 &lt;firstname&gt;Jack&lt;/firstname&gt;
          &lt;/person&gt;
          &lt;person&gt;
                 &lt;firstname&gt;James&lt;/firstname&gt;
          &lt;/person&gt;
  &lt;/persons&gt;
  </code></pre>
  
  <p>If I want to access the 3rd firstname node (passed dynamically and stored in i, assumed to be 3 here), how do I do that? My weird attempt follows:</p>
  
  <pre><code>var i=3;
  $(xml).find('firstname').each(function(idx){
         if (idx==i) alert($(this).text());
  });
  </code></pre>
  
  <p>It does fetch me the right content... but it just feels wrong to me especially the looping part. Basically I'm looping through the whole tree using .each()! Is there any better approach than this? Something that'd take me to the nth node directly like:</p>
  
  <pre><code>alert( $(xml).find('firstname')[idx].text() ); // where idx=n
  </code></pre>
  
  <p>I'm new to jquery so please excuse my jquery coding approach. </p>