►
Run
# Python XML Parsing import xml.etree.ElementTree as ET root = ET.parse('sample.xml').getroot() # get all attributes attributes = root.attrib print(attributes) # extract a particular attribute year = attributes.get('year') print('year : ',year)
Output