title: python xml.etree.ElementTree append to subelement
body: <p>I am trying to use xml.etree.ElementTree to parse a xml file, find a specific tag, append a child to that tag, append another child to the newly created tag and add text to the latter child.  </p>
  
  <p>My XML:</p>
  
  <pre><code>&lt;root&gt;
  &lt;a&gt;
      &lt;b&gt;
        &lt;c&gt;text1&lt;/c&gt;
      &lt;/b&gt;
      &lt;b&gt;
        &lt;c&gt;text2&lt;/c&gt;
     &lt;/b&gt;
  &lt;/a&gt;
  &lt;/root&gt;    
  </code></pre>
  
  <p>Desired XML:</p>
  
  <pre><code>&lt;root&gt;
  &lt;a&gt;
      &lt;b&gt;
        &lt;c&gt;text1&lt;/c&gt;
      &lt;/b&gt;
      &lt;b&gt;
        &lt;c&gt;text2&lt;/c&gt;
     &lt;/b&gt;
      &lt;b&gt;
        &lt;c&gt;text3&lt;/c&gt;
     &lt;/b&gt;
  &lt;/a&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Current code:</p>
  
  <pre><code>import xml.etree.ElementTree as ET
  tree = ET.parse('test.xml')
  root = tree.getroot()
  
  
  for x in root.iter():
      if (x.tag == 'a'):
          ET.SubElement(x, 'b')
          ET.SubElement(x, 'c')
          #add text
  </code></pre>
  
  <p>This seems to work except 'c' appends as a child of 'a' rather then 'b' </p>
  
  <p>Like so:</p>
  
  <pre><code>&lt;root&gt;
  &lt;a&gt;
      &lt;b&gt;
        &lt;c&gt;test1&lt;/c&gt;
      &lt;/b&gt;
      &lt;b&gt;
        &lt;c&gt;test2&lt;/c&gt;
      &lt;/b&gt;
    &lt;b /&gt;&lt;c/&gt;&lt;/a&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Also, how do I add text to the newly created element 'c'?  I could iterate through until I find the a tag 'c' that has no text but there must be a better way.</p>