title: How to convert an XML file to nice pandas dataframe?
body: <p>Let's assume that I have an XML like this:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;author type=&quot;XXX&quot; language=&quot;EN&quot; gender=&quot;xx&quot; feature=&quot;xx&quot; web=&quot;foobar.com&quot;&gt;
      &lt;documents count=&quot;N&quot;&gt;
          &lt;document KEY=&quot;e95a9a6c790ecb95e46cf15bee517651&quot; web=&quot;www.foo_bar_exmaple.com&quot;&gt;&lt;![CDATA[A large text with lots of strings and punctuations symbols [...]
  ]]&gt;
          &lt;/document&gt;
          &lt;document KEY=&quot;bc360cfbafc39970587547215162f0db&quot; web=&quot;www.foo_bar_exmaple.com&quot;&gt;&lt;![CDATA[A large text with lots of strings and punctuations symbols [...]
  ]]&gt;
          &lt;/document&gt;
          &lt;document KEY=&quot;19e71144c50a8b9160b3f0955e906fce&quot; web=&quot;www.foo_bar_exmaple.com&quot;&gt;&lt;![CDATA[A large text with lots of strings and punctuations symbols [...]
  ]]&gt;
          &lt;/document&gt;
          &lt;document KEY=&quot;21d4af9021a174f61b884606c74d9e42&quot; web=&quot;www.foo_bar_exmaple.com&quot;&gt;&lt;![CDATA[A large text with lots of strings and punctuations symbols [...]
  ]]&gt;
          &lt;/document&gt;
      &lt;/documents&gt;
  &lt;/author&gt;
  </code></pre>
  <p>I would like to read this XML file and convert it to a pandas DataFrame:</p>
  <pre class="lang-shell prettyprint-override"><code>key                                         type     language    feature            web                         data
  e95324a9a6c790ecb95e46cf15bE232ee517651      XXX        EN          xx      www.foo_bar_exmaple.com     A large text with lots of strings and punctuations symbols [...]
  bc360cfbafc39970587547215162f0db             XXX        EN          xx      www.foo_bar_exmaple.com     A large text with lots of strings and punctuations symbols [...]
  19e71144c50a8b9160b3cvdf2324f0955e906fce     XXX        EN          xx      www.foo_bar_exmaple.com     A large text with lots of strings and punctuations symbols [...]
  21d4af9021a174f61b8erf284606c74d9e42         XXX        EN          xx      www.foo_bar_exmaple.com     A large text with lots of strings and punctuations symbols [...]
  </code></pre>
  <p>This is what I already tried, but I am getting some errors and probably there is a more efficient way of doing this task:</p>
  <pre class="lang-python prettyprint-override"><code>from lxml import objectify
  import pandas as pd
  
  path = 'file_path'
  xml = objectify.parse(open(path))
  root = xml.getroot()
  root.getchildren()[0].getchildren()
  df = pd.DataFrame(columns=('key','type', 'language', 'feature', 'web', 'data'))
  
  for i in range(0,len(xml)):
      obj = root.getchildren()[i].getchildren()
      row = dict(zip(['key','type', 'language', 'feature', 'web', 'data'], [obj[0].text, obj[1].text]))
      row_s = pd.Series(row)
      row_s.name = i
      df = df.append(row_s)
  </code></pre>
  <p>Could anybody provide me a better aproach for this problem?</p>