Я пытаюсь заставить python распечатать все названия фильмов в файле XML, но я не могу понять это.Я довольно новичок в Python, может кто-нибудь подсказать мне правильное направление?
Мой код пока:
import xml.etree.ElementTree as ET
tree = ET.parse('text.xml')
root = tree.getroot()
for elem in root:
print(elem.find('movie').get('title'))
Файл XML:
<collection>
<genre category="Action">
<decade years="1980s">
<movie favorite="True" title="Indiana Jones: The raiders of the lost Ark">
<format multiple="No">DVD</format>
<year>1981</year>
<rating>PG</rating>
<description>
'Archaeologist and adventurer Indiana Jones
is hired by the U.S. government to find the Ark of the
Covenant before the Nazis.'
</description>
</movie>
<movie favorite="True" title="THE KARATE KID">
<format multiple="Yes">DVD,Online</format>
<year>1984</year>
<rating>PG</rating>
<description>None provided.</description>
</movie>
<movie favorite="False" title="Back 2 the Future">
<format multiple="False">Blu-ray</format>
<year>1985</year>
<rating>PG</rating>
<description>Marty McFly</description>
</movie>
</decade>
</genre>
</collection>