Category: xml

Problem

Parse XML with ElementTree.

Solution

  root = ET.fromstring(xml_text)
for child in root.findall('item'):
    print(child.get('id'))
  

Notes

  • Adapt variable names and paths to your project
  • Add error handling for production use
  • See related chapters in the Learning Path