title: Parse multiple xml files in Python
body: <p>I am stuck with a problem here. So I want to parse multiple xml files with the same structure within it. I was already able to get all the locations for each file and save them into three different lists, since there are three different types of xml structures. Now I want to create three  functions (for each list), which is looping through the lists and parse the information I need. Somehow I am not able to do it. Anybody here who could give me a hint how to do it? </p>
  
  <pre><code>import os
  import glob
  import xml.etree.ElementTree as ET
  import fnmatch
  import re
  import sys
  
  
  #### Get the location of each XML file and save them into a list ####
  
  all_xml_list =[]                                                                                                                                       
  
  def locate(pattern,root=os.curdir):
      for path, dirs, files in os.walk(os.path.abspath(root)):
          for filename in fnmatch.filter(files,pattern):
              yield os.path.join(path,filename)
  
  for files in locate('*.xml',r'C:\Users\Lars\Documents\XML-Files'):
      all_xml_list.append(files)
  
  
  #### Create lists by GameDay Events ####
  
  
  xml_GameDay_Player   = [x for x in all_xml_list if 'Player' in x]                                                             
  xml_GameDay_Team     = [x for x in all_xml_list if 'Team' in x]                                                             
  xml_GameDay_Match    = [x for x in all_xml_list if 'Match' in x]  
  </code></pre>
  
  <p>The XML file looks like this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;sports-content xmlns:imp="url"&gt;
    &lt;sports-metadata date-time="20160912T000000+0200" doc-id="sports_event_" publisher="somepublisher" language="en_EN" document-class="player-statistics"&gt;
      &lt;sports-title&gt;player-statistics-165483&lt;/sports-title&gt;
    &lt;/sports-metadata&gt;
    &lt;sports-event&gt;
      &lt;event-metadata id="E_165483" event-key="165483" event-status="post-event" start-date-time="20160827T183000+0200" start-weekday="saturday" heat-number="1" site-attendance="52183" /&gt;
      &lt;team&gt;
        &lt;team-metadata id="O_17" team-key="17"&gt;
          &lt;name full="TeamName" nickname="NicknameoftheTeam" imp:dfl-3-letter-code="NOT" official-3-letter-code="" /&gt;
        &lt;/team-metadata&gt;
        &lt;player&gt;
          &lt;player-metadata player-key="33201" uniform-number="1"&gt;
            &lt;name first="Max" last="Mustermann" full="Max Mustermann" nickname="Mäxchen" imp:extensive="Name" /&gt;
          &lt;/player-metadata&gt;
          &lt;player-stats stats-coverage="standard" date-coverage-type="event" minutes-played="90" score="0"&gt;
            &lt;rating rating-type="standard" imp:rating-value-goalie="7.6" imp:rating-value-defenseman="5.6" imp:rating-value-mid-fielder="5.8" imp:rating-value-forward="5.0" /&gt;
            &lt;rating rating-type="grade" rating-value="2.2" /&gt;
            &lt;rating rating-type="index" imp:rating-value-goalie="7.6" imp:rating-value-defenseman="3.7" imp:rating-value-mid-fielder="2.5" imp:rating-value-forward="1.2" /&gt;
            &lt;rating rating-type="bemeister" rating-value="16.04086" /&gt;
            &lt;player-stats-soccer imp:duels-won="1" imp:duels-won-ground="0" imp:duels-won-header="1" imp:duels-lost-ground="0" imp:duels-lost-header="0" imp:duels-lost="0" imp:duels-won-percentage="100" imp:passes-completed="28" imp:passes-failed="4" imp:passes-completions-percentage="87.5" imp:passes-failed-percentage="12.5" imp:passes="32" imp:passes-short-total="22" imp:balls-touched="50" imp:tracking-distance="5579.80" imp:tracking-average-speed="3.41" imp:tracking-max-speed="23.49" imp:tracking-sprints="0" imp:tracking-sprints-distance="0.00" imp:tracking-fast-runs="3" imp:tracking-fast-runs-distance="37.08" imp:tracking-offensive-runs="0" imp:tracking-offensive-runs-distance="0.00" dfl-distance="5579.80" dfl-average-speed="3.41" dfl-max-speed="23.49"&gt;
              &lt;stats-soccer-defensive saves="5" imp:catches-punches-crosses="3" imp:catches-punches-corners="0" goals-against-total="1" imp:penalty-saves="0" imp:clear-cut-chance="0" /&gt;
              &lt;stats-soccer-offensive shots-total="0" shots-on-goal-total="0" imp:shots-off-post="0" offsides="0" corner-kicks="0" imp:crosses="0" assists-total="0" imp:shot-assists="0" imp:freekicks="3" imp:miss-chance="0" imp:throw-in="0" imp:punt="2" shots-penalty-shot-scored="0" shots-penalty-shot-missed="0" dfl-assists-total="0" imp:shots-total-outside-box="0" imp:shots-total-inside-box="0" imp:shots-foot-inside-box="0" imp:shots-foot-outside-box="0" imp:shots-total-header="0" /&gt;
              &lt;stats-soccer-foul fouls-commited="0" fouls-suffered="0" imp:yellow-red-cards="0" imp:red-cards="0" imp:yellow-cards="0" penalty-caused="0" /&gt;
            &lt;/player-stats-soccer&gt;
          &lt;/player-stats&gt;
        &lt;/player&gt;
      &lt;/team&gt;
    &lt;/sports-event&gt;
  &lt;/sports-content&gt;
  </code></pre>
  
  <p>I want to extract everything which is within the "player meta tag" and "player-stats coverage" and "player stats soccer" tag. </p>