'''Created Mar 18, 2021 Levi''' from xml.etree import ElementTree as ET import xlsxwriter as xlsw import openpyxl as xl xml = ET.parse('D390_2020_10_21480386.xml') root = xml.getroot() data = [] for ch in root: if 'tip' in ch.attrib: d = {root.attrib['cui']: [ch.attrib['tip'], ch.attrib['tara']]} data.append(d) print(data)