title: Fetch data from xml using ElementTree in Python
body: <p>I am trying to extract some data from a xml file. Given below is how the xml looks.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Stores&gt;
    &lt;Store&gt;
  &lt;Action&gt;new&lt;/Action&gt;
  &lt;StoreID&gt;1001&lt;/StoreID&gt;
  &lt;EmpID/&gt;
  &lt;Agent&gt;
    &lt;Name/&gt;
    &lt;EmpName&gt;Scott&lt;/EmpName&gt;
  &lt;/Name&gt;
  &lt;BillData&gt;
    &lt;BillInfo&gt;
      &lt;Action&gt;new&lt;/Action&gt;
      &lt;CustName&gt;&lt;/CustName&gt;
      &lt;BillNumber&gt;3343&lt;/BillNumber&gt;
     &lt;/BillInfo&gt;
    &lt;/BillData&gt;
   &lt;/Store&gt;
  &lt;/Stores&gt;
  </code></pre>
  
  <p>I am trying to fetch each of the columns along with its data from the above dataset. Given below is what I have achieved thus far:</p>
  
  <pre><code>import xml.etree.ElementTree as ET
  tree = ET.parse('file.xml')
  root = tree.getroot()
      for elem in root:
          for subelem in elem:
          print(subelem.tag)
          print(subelem.text)
  </code></pre>
  
  <p>Output is as below:</p>
  
  <pre><code>Action
  new
  StoreID
  1001
  Agent
  
  
  BillData
  </code></pre>
  
  <p>I am trying to extract data that is at the child level. Could anyone advice how could I extract data stored under 'BillInfo' namely</p>
  
  <pre><code>Action
  new
  CustName
  BillNumber
  3343
  </code></pre>