title: Count the number of nodes in an XML snippet using Javascript/E4X
body: <p>Consider this problem:</p>
  
  <p>Using Javascript/E4X, in a non-browser usage scenario (a Javascript HL7 integration engine), there is a variable holding an XML snippet that could have multiple repeating nodes. </p>
  
  <pre><code>&lt;pets&gt;       
   &lt;pet type="dog"&gt;Barney&lt;/pet&gt;
   &lt;pet type="cat"&gt;Socks&lt;/pet&gt;
  &lt;/pets&gt;
  </code></pre>
  
  <p><strong>Question</strong>: How to get the count of the number of pet nodes in Javascript/E4X ?</p>
  
  <p>EDIT: To clarify, this question should be around <a href="http://en.wikipedia.org/wiki/E4x" rel="noreferrer">E4X (ECMAScript for XML)</a>. Apologies to those who answered without this information. I should have researched &amp; posted this info beforehand.</p>