title: lxml.etree iterparse() and parsing element completely
body: <p>I have an XML file with nodes that looks like this:</p>
  
  <pre><code>&lt;trkpt lat="-37.7944415" lon="144.9616159"&gt;
    &lt;ele&gt;41.3681107&lt;/ele&gt;
    &lt;time&gt;2015-04-11T03:52:33.000Z&lt;/time&gt;
    &lt;speed&gt;3.9598&lt;/speed&gt;
  &lt;/trkpt&gt;
  </code></pre>
  
  <p>I am using lxml.etree.iterparse() to iteratively parse the tree. I loop over each trkpt element's children and want to print the text value of the children nodes. E.g.</p>
  
  <pre><code>for event, element in etree.iterparse(infile, events=("start", "end")):
      if element.tag == NAMESPACE + 'trkpt':
          for child in list(element):
              print child.text
  </code></pre>
  
  <p>The problem is that at this stage the node has no text, so the output of the print is 'None'. </p>
  
  <p>I have validated this by replacing the 'print child.text' statement with 'print etree.tostring(child)' and the output looks like this </p>
  
  <pre><code>&lt;ele/&gt;
  &lt;time/&gt;
  &lt;speed/&gt;    
  </code></pre>
  
  <p>According to the documentation, "Note that the text, tail, and children of an Element are not necessarily present yet when receiving the start event. Only the end event guarantees that the Element has been parsed completely."</p>
  
  <p>So I changed my for loop to this, note the 'if event == "end":' statement </p>
  
  <pre><code>for event, element in etree.iterparse(infile, events=("start", "end")):
      if element.tag == NAMESPACE + 'trkpt':
          if event == "end":
              for child in list(element):
                  print child.text
  </code></pre>
  
  <p>But I am still getting the same results. Any help would be greatly appreciated.</p>