I'm beginnning with data analysis, I want to parse an XML file in order to analyze data, Here is a portion of my XML file :
<?xml version="1.0" encoding="UTF-8"?>
<SoccerFeed>
<SoccerDocument>
<Team>
<Founded>1919</Founded>
<Name>Angers</Name>
<Player uID="p40511">
<Name>Denis Petric</Name>
<Position>Goalkeeper</Position>
<Stat Type="first_name">Denis</Stat>
<Stat Type="last_name">Petric</Stat>
<Stat Type="preferred_foot">Left</Stat>
</Player>
<Player uID="p119744">
<Name>Mathieu Michel</Name>
<Position>Goalkeeper</Position>
<Stat Type="first_name">Mathieu</Stat>
<Stat Type="preferred_foot">Right</Stat>
</Player>
</Team>
</SoccerDocument>
</SoccerFeed>
How can I access to the preferred_foot in Stat tag ? Here is my python code to access these data :
dom = ElementTree.parse(full_file)
teams = dom.findall('SoccerDocument/Team')
for t in teams:
team_name = t.find('Name').text
founded = t.find('Founded').text
players = t.findall('Player')
for pl in players:
player_name = pl.find('Name').text
player_position = pl.find('Position').text
preferred_foot = pl.find('Stat[@Type="preferred_foot"]')