Having challenge with xml file

48 views Asked by At

want to print this xml file such that I can be able to loop through it. my aim is to combine it with a csv file having the same column name, before creating a database with this combined file. I'm not allow to use non standard Libraries.

code------

xml_file = ET.parse("E:/Research work/My connect/Sam/CETM50 - 2022_3 - Assignment Data/user_data.xml")

get the parent tag

root = xml_file.getroot()

print the attributes of the first tag

e = ET.tostring(xml_file.getroot(), encoding='unicode', method='xml') print(e)

output

<user firstName="Jayne" lastName="Wilson" age="69" sex="Female" retired="False" dependants="1" marital_status="divorced" salary="36872" pension="0" company="Wall, Reed and Whitehouse" commute_distance="10.47" address_postcode="TD95 7FL"

0

There are 0 answers