title: parse data from xml using python 3
body: <p>Please find the <code>mwe</code> xml file (The actual file is 81k lines long, I am showing a tiny part).</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
  &lt;modeling&gt;
    &lt;dos&gt;
      &lt;i name=&quot;efermi&quot;&gt;     -2.48501882 &lt;/i&gt;
      &lt;total&gt;
        &lt;array&gt;
          &lt;dimension dim=&quot;1&quot;&gt;gridpoints&lt;/dimension&gt;
          &lt;dimension dim=&quot;2&quot;&gt;spin&lt;/dimension&gt;
          &lt;field&gt;energy&lt;/field&gt;
          &lt;field&gt;total&lt;/field&gt;
          &lt;field&gt;integrated&lt;/field&gt;
          &lt;set&gt;
            &lt;set comment=&quot;spin 1&quot;&gt;
              &lt;r&gt;   -55.6029     0.0000     0.0000 &lt;/r&gt;
              &lt;r&gt;   -55.3940     0.0000     0.0000 &lt;/r&gt;
              &lt;r&gt;   -55.1850     0.0000     0.0000 &lt;/r&gt;
              &lt;r&gt;   -54.9761     0.0000     0.0000 &lt;/r&gt;
            &lt;/set&gt;
            &lt;set comment=&quot;spin 2&quot;&gt;
              &lt;r&gt;   -55.6029     0.0000     0.0000 &lt;/r&gt;
              &lt;r&gt;   -55.3940     0.0000     0.0000 &lt;/r&gt;
              &lt;r&gt;   -55.1850     0.0000     0.0000 &lt;/r&gt;
              &lt;r&gt;   -54.9761     0.0000     0.0000 &lt;/r&gt;
            &lt;/set&gt;
          &lt;/set&gt;
        &lt;/array&gt;
      &lt;/total&gt;
      &lt;partial&gt;
        &lt;array&gt;
          &lt;dimension dim=&quot;1&quot;&gt;gridpoints&lt;/dimension&gt;
          &lt;dimension dim=&quot;2&quot;&gt;spin&lt;/dimension&gt;
          &lt;dimension dim=&quot;3&quot;&gt;ion&lt;/dimension&gt;
          &lt;field&gt;energy&lt;/field&gt;
          &lt;field&gt;    s&lt;/field&gt;
          &lt;field&gt;   py&lt;/field&gt;
          &lt;field&gt;   pz&lt;/field&gt;
          &lt;field&gt;   px&lt;/field&gt;
          &lt;field&gt;  dxy&lt;/field&gt;
          &lt;field&gt;  dyz&lt;/field&gt;
          &lt;field&gt;  dz2&lt;/field&gt;
          &lt;field&gt;  dxz&lt;/field&gt;
          &lt;field&gt;x2-y2&lt;/field&gt;
          &lt;set&gt;
            &lt;set comment=&quot;ion 1&quot;&gt;
              &lt;set comment=&quot;spin 1&quot;&gt;
                &lt;r&gt;   -55.6029     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000 &lt;/r&gt;
                &lt;r&gt;   -55.3940     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000 &lt;/r&gt;
                &lt;r&gt;   -55.1850     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000 &lt;/r&gt;
                &lt;r&gt;   -54.9761     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000 &lt;/r&gt;
              &lt;/set&gt;
              &lt;set comment=&quot;spin 2&quot;&gt;
                &lt;r&gt;   -55.6029     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000 &lt;/r&gt;
                &lt;r&gt;   -55.3940     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000 &lt;/r&gt;
                &lt;r&gt;   -55.1850     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000 &lt;/r&gt;
                &lt;r&gt;   -54.9761     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000     0.0000 &lt;/r&gt;
              &lt;/set&gt;
            &lt;/set&gt;
          &lt;/set&gt;
        &lt;/array&gt;
      &lt;/partial&gt;
    &lt;/dos&gt;
  &lt;/modeling&gt;
  </code></pre>
  <p>The dos tag nested well below, and the values in the component <code>spin 1</code> etc are not necessarily 0.
  I have managed to reach till <code>dos</code> tag, and get the <code>efermi</code> value, but don't understand how to get the sets separately and selectively so that I can plot it using <code>matplotlib</code>.</p>
  <p>This is my current code:</p>
  <pre><code>#!/usr/bin/env python
  import xml.etree.ElementTree as ET
  
  tree = ET.parse(&quot;trial.xml&quot;)
  root = tree.getroot()
  
  for elem in root:
    print(elem.tag)
    if elem.tag == 'dos':
      for x in elem:
        print(x.attrib.get('name'), x.text)
  </code></pre>