title: How to count the number of children of a node in an XML document in Java?
body: <p>I have xml similar to this:</p>
  
  <pre><code>&lt;parent&gt;
     &lt;child1&gt;
     &lt;child2&gt;
     &lt;child3&gt;
  &lt;/parent&gt;
  </code></pre>
  
  <p>Now there are 3 children for parent tag.So i need to get number of childern in parent tag.</p>
  
  <p>I am using the following code but it is not working:</p>
  
  <pre><code>NodeList nodeList = doc.getElementsByTagName("a"); nodeList.getChildnodes();
  </code></pre>
  
  <p>How to do this please?</p>