title: How to get the size/length of sub-elements within an XML tag using python
body: <p>I'm newbie to python and I was wondering how to get the size or number of sub elements within a parent tag lets say <code>participants</code>. The idea is to get the number of <code>participant</code> within <code>participants</code> tag.</p>
  
  <p>Here is the xml:</p>
  
  <pre><code>&lt;participants&gt;
    &lt;participant&gt;
      &lt;userId&gt;James&lt;/userId&gt;
      &lt;role&gt;Author&lt;/role&gt;
    &lt;/participant&gt;
    &lt;participant&gt;
      &lt;userId&gt;Alex&lt;/userId&gt;
      &lt;role&gt;Reader&lt;/role&gt;
    &lt;/participant&gt;
  &lt;/participants&gt;
  </code></pre>
  
  <p>I'm using xml:</p>
  
  <p><code>import xml.etree.ElementTree as ET</code> as the module </p>
  
  <p>and <code>ET</code> is assigned <code>dom = ET.fromstring(output)</code></p>
  
  <p>so far, to parse xml, I have written the following code which works:</p>
  
  <pre><code>for participant in dom.iter('participant'): 
      userId = participant.find('userId').text
      role = participant.find('role').text
  </code></pre>
  
  <p>But I want to get the size/length of number of <code>participant</code> in <code>participants</code> tag and this is what I'm trying to do but it doesn't give me the length:</p>
  
  <pre><code>print 'length', dom.findall('participants').length
  </code></pre>
  
  <p>The output I want should be:</p>
  
  <pre><code>length 2
  </code></pre>