title: Jquery ChildElementCount
body: <p>Sorry for the jquery ajax xml 101 question ...</p>
  
  <p>I have 2 questions:
  1) Counting the child nodes inside the <code>&lt;RESULTS&gt;</code>. In this case there's only element happens to be called OBS. I want to know the jquery method for doing this. I have it with long hand javascript.
  2) Can you advise the preferred method for accessing these counts (read down).</p>
  
  <p>XML file looks like this...</p>
  
  <pre><code>&lt;TABLE&gt;
   &lt;RESULTS&gt;
    &lt;OBS&gt;..&lt;/OBS&gt;
   &lt;/RESULTS&gt;
   &lt;RESULTS&gt;
    &lt;OBS&gt;..&lt;/OBS&gt;
   &lt;/RESULTS&gt;
  &lt;/TABLE&gt;
  </code></pre>
  
  <p>There are 2 <code>&lt;RESULTS&gt;</code> and 1 child <code>&lt;OBS&gt;</code> returned.
  I've got that covered with ...</p>
  
  <p>Long hand Javascript:</p>
  
  <pre><code>var items = request.responseXML.getElementsByTagName('RESULTS');
  console.log("child Element Count= ",items[0].childElementCount); // will return 1 = OBS
  console.log("nodes Count= ",items.length); // will return 2 =RESULTS
  </code></pre>
  
  <p>So we're good with that but with jquery.</p>
  
  <p>Short hand Jquery:</p>
  
  <pre><code>var count=$(result).find("RESULTS").size();         
  var countLength=$(result).find("RESULTS").length; 
  </code></pre>
  
  <p>Both will return "2".
  How do I get to the count of the child elements? In this case the answer would be 1 as there's just <code>&lt;OBS&gt;</code></p>
  
  <p>Thanks in advance.</p>