import xml.etree.ElementTree as ET rfile = 'sample.osm' tree = ET.parse(rfile) root = tree.getroot() print('root tag: {}'.format(root.tag)) print('root attrib: {}'.format(root.attrib)) for child in root: print('child tag: {}'.format(child.tag)) print('child attrib: {}'.format(child.attrib))