title: lxml fails to extract all text when nested elements are present?
body: <p>I am parsing some large xml files, with the goal of extracting all raw text contained under the <code>body</code> element. I don't in which sub-elements the text occurs - I'm just concatenating all the text.</p>
  
  <p>The relevant bit of code I'm using to achieve this is:</p>
  
  <pre><code># find all instances of `body`
  result = []
  for body in tree.findall('.//{*}body'): 
      # iterate recursively over all sub-elemetns of `body`
      for node in body.iter('*'):
          # append any text if it exists
          if node.text:
              # handle the text
              result.append(node.text.strip())
  print(' '.join(result))
  </code></pre>
  
  <p>Pretty straightforward, and I <em>thought</em> it was working, but I've found some cases where it's failing that I'm not sure how to work around. Here's a minimal example extracted from an xml file:</p>
  
  <pre><code>&lt;cja:body&gt;
    &lt;ce:sections xmlns:ce=".../xml/common/schema"&gt;
      &lt;ce:para view="all"&gt;For scyptolin A or B the IC
                  &lt;ce:inf loc="post"&gt;50&lt;/ce:inf&gt; was erroneously calculated at 3.1 μg/ml. The correct IC
                  &lt;ce:inf loc="post"&gt;50&lt;/ce:inf&gt; was determined at 0.16 μg/ml for both scyptolins.
              &lt;/ce:para&gt;
    &lt;/ce:sections&gt;
  &lt;/cja:body&gt;
  </code></pre>
  
  <p>If I run the above code block on this xml, the output is:</p>
  
  <pre><code>For scyptolin A or B the IC 50 50
  </code></pre>
  
  <p>So the problem is, for the <code>para</code> node, <code>node.text</code> only seems to retrieve text that occurs <em>before</em> the nested <code>inf</code> element. How do I extract all the text, not just that occurring before nested elements? To be clear, the desired output here would be:</p>
  
  <pre><code>For scyptolin A or B the IC 50 was erroneously calculated at 3.1 μg/ml. The correct IC 50 was determined at 0.16 μg/ml for both scyptolins.
  </code></pre>