'How can I create multiple dataframes from xml file in python?

I have an xml output file from a simulation of the structure:

.
.
.
  <me:populationList T="295" conc="2.61871e+18">
    <me:population time="1e-11" logTime="-11">
      <me:pop ref="A">0.999996</me:pop>
      <me:pop ref="B">4.32274e-06</me:pop>
      <me:pop ref="C">1.25314e-09</me:pop>
      <me:pop ref="D">1.92213e-10</me:pop>    
      <me:pop ref="E">1.95037e-14</me:pop>
      <me:pop ref="F">3.09628e-10</me:pop>
      <me:pop ref="G">1.3979e-18</me:pop>
    </me:population>
    <me:population time="1.25893e-11" logTime="-10.9">
      <me:pop ref="A">0.999995</me:pop>
      <me:pop ref="B">5.436e-06</me:pop> 
      <me:pop ref="C">1.83468e-09</me:pop>
      <me:pop ref="D">3.5602e-10</me:pop>
      <me:pop ref="E">1.95551e-14</me:pop>
      <me:pop ref="F">5.87077e-10</me:pop>
      <me:pop ref="G">3.04455e-18</me:pop>
    </me:population>
.
.
.

  <me:populationList T="212" conc="2.27747e+17">
    <me:population time="1e-11" logTime="-11">
      <me:pop ref="A">0.999995</me:pop>
      <me:pop ref="B">4.59651e-06</me:pop>
      <me:pop ref="C">5.4886e-10</me:pop>
      <me:pop ref="D">8.88425e-11</me:pop>
      <me:pop ref="E">8.33418e-19</me:pop>
      <me:pop ref="F">1.34764e-10</me:pop>
      <me:pop ref="G">3.22323e-20</me:pop>
    </me:population>
    <me:population time="1.25893e-11" logTime="-10.9">
      <me:pop ref="A">0.999994</me:pop>
      <me:pop ref="B">5.78328e-06</me:pop>
      <me:pop ref="C">8.02914e-10</me:pop>
      <me:pop ref="D">1.64467e-10</me:pop>
      <me:pop ref="E">1.95213e-18</me:pop>
      <me:pop ref="F">2.55806e-10</me:pop>
      <me:pop ref="G">7.03021e-20</me:pop>
    </me:population>...

I would like to be able to extract each populationList in the xml file into a separate dataframe so that this can be exported as a csv.

I can do this for an xml file that has one populationList, but I am unsure how to do this when the xml file contains multiple populationLists?

This is the desired output:

df_295:

Time A B C D E F G
1e-11
1.25893e-11

df_212:

Time A B C D E F G
1e-11
1.25893e-11


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source