title: Create dataframe of certain XML element's text python pandas
body: <p>I am trying to create a dataframe out the XML code as shown below</p>
  <pre><code>&lt;Structure&gt;
      &lt;Field&gt;
          &lt;Field_Name&gt;GAMEREF&lt;/Field_Name&gt;
          &lt;Field_Type&gt;Numeric&lt;/Field_Type&gt;
          &lt;Field_Len&gt;4&lt;/Field_Len&gt;
          &lt;Field_Dec&gt;0&lt;/Field_Dec&gt;
      &lt;/Field&gt;
      ...
      &lt;Field&gt;
          &lt;Field_Name&gt;WINLOSS&lt;/Field_Name&gt;
          &lt;Field_Type&gt;Character&lt;/Field_Type&gt;
          &lt;Field_Len&gt;1&lt;/Field_Len&gt;
          &lt;Field_Dec&gt;0&lt;/Field_Dec&gt;
      &lt;/Field&gt;
  &lt;/Structure&gt;
  
  &lt;Records&gt;
      &lt;Record&gt;
          &lt;GAMEREF&gt;1217&lt;/GAMEREF&gt;
          &lt;YEAR&gt;2021&lt;/YEAR&gt;
          (MORE ELEMENTS I DO NOT CARE ABOUT)
          &lt;GAMENO&gt;1&lt;/GAMENO&gt;
          &lt;WINLOSS&gt;W&lt;/WINLOSS&gt;
      &lt;/Record&gt;
      ...
      &lt;Record&gt;
          &lt;GAMEREF&gt;1220&lt;/GAMEREF&gt;
          &lt;YEAR&gt;2021&lt;/YEAR&gt;
          (MORE ELEMENTS I DO NOT CARE ABOUT)
          &lt;GAMENO&gt;4&lt;/GAMENO&gt;
          &lt;WINLOSS&gt;L&lt;/WINLOSS&gt;
      &lt;/Record&gt;
  &lt;/Records&gt;
  </code></pre>
  <p>The structure section of the XML code that is irrelevant to the dataframe I am trying to create.</p>
  <p>I am trying to only use the XML elements of GAMEREF, YEAR, GAMENO, and WINLOSS as there are more in the XML for the Record elements.</p>
  <p>I have tried using code as shown below to get this to work, but when I run the code I get the error of &quot;AttributeError: 'NoneType' object has no attribute 'text'&quot;</p>
  <p>Code is below.</p>
  <pre><code>import pandas as pd
  import xml.etree.ElementTree as et
  
  xtree = et.parse(&quot;gamedata.xml&quot;)
  xroot = xtree.getroot()
  
  df_cols = [&quot;GAME REF&quot;,&quot;YEAR&quot;, &quot;GAME NO&quot;, &quot;WIN LOSS&quot;]
  rows = []
  
  for child in xroot.iter():
       s_gameref = child.find('GAMEREF').text,
       s_year = child.find('YEAR').text,
       s_game_no = child.find('GAMENO').text,
       s_winloss = child.find('WINLOSS').text
  
       rows.append({&quot;GAME REF&quot;: s_gameref,&quot;YEAR&quot;: s_year, 
               &quot;GAME NO&quot;: s_game_no, &quot;WIN LOSS&quot;: s_winloss})
  
  df = pd.DataFrame(rows, columns = df_cols)
  </code></pre>
  <p>The code is based off other stuff I have seen on the Stack and other sites, but nothing is working yet.</p>
  <p>Ideal dataframe output is below</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>GAME REF</th>
  <th>YEAR</th>
  <th>GAME NO</th>
  <th>WIN LOSS</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1217</td>
  <td>2021</td>
  <td>1</td>
  <td>W</td>
  </tr>
  <tr>
  <td>1218</td>
  <td>2021</td>
  <td>2</td>
  <td>W</td>
  </tr>
  <tr>
  <td>1219</td>
  <td>2021</td>
  <td>3</td>
  <td>L</td>
  </tr>
  <tr>
  <td>1220</td>
  <td>2021</td>
  <td>4</td>
  <td>L</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Thanks</p>
  <p>EDIT - NOT SURE WHAT IS GOING ON WITH MY TABLE, BUT IT SHOULD LOOK LIKE THIS
  <a href="https://i.stack.imgur.com/rwuiF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rwuiF.png" alt="table" /></a></p>