title: How to Iterate through XML tree children from chosen parent?
body: <p>I want to iterate through my XML tree and retrieve all children attributes from selected parent. This is my parsing setup:   </p>
  
  <pre><code>import xml.etree.ElementTree as ET
  
  file_name = 'myXML.xml'
  tree = ET.parse(file_name)
  root = tree.getroot()
  </code></pre>
  
  <p>The function I have uses a for loop, but you will need a for loop per layer of generations:
  Essentially, each parent loops through each child and returns <code>.tag</code>, <code>.text</code>, &amp; <code>.attrib</code>:</p>
  
  <p>Is there a method of looping through and collecting all this data without knowing the number of layers?</p>
  
  <pre><code>def data_dump(k, mD, st):
      for na in mD.iter(k):
          for a in na:
              print(st + '&gt; a:: ', a.tag., a.text, a.attrib)
              for b in a:
                  print('|--&gt;', ' b:: ', b.tag, b.text, b.attrib)
                  for c in b:
                      print('|----&gt;', ' c:: ', c.tag, c.text, c.attrib)
                      for d in c:
                          print('|------&gt;', ' d:: ', d.tag, d.text, d.attrib)
  
  </code></pre>
  
  <p>These are my test cases:</p>
  
  <pre><code>data_dump('Title', root, 'TITLE')
  data_dump('Comment', root, 'COM')
  data_dump('Steps', root, 'STEP')
  data_dump('Transitions', root, 'TRANS')
  data_dump('Branches', root, 'BRAN')
  data_dump('Connections', root, 'CONN')
  data_dump('Sequence', root, 'SEQ')
  </code></pre>