Click here to Skip to main content
14,971,296 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I have a XML file where i need to read it and save each column to an excel file. Can someone pls help .

I have some lines after the declare statement , But I want to parse from the table1 till /table1 can someone help me ?

XML
<?xml version="1.0" encoding="Metadata" ?>
<DECLARE  lmsid ="asdhgh"
...........
</table1 name ="employee table" name ="E1 Enterprises" refid ="201"
<data id = "ABC" emp = "dt">
<country id ="m1" name =dt1">
<rank text> "data"</rank text>
<rank textd> "direction"</rank textd>
<reference>
<ref id ="9900m" id1="1000" ref="URL">
</reference>
</country>
<data id = "xyz" emp = "dt1">
<country id ="m2" name =dt2">
<rank text> "data1"</rank text>
<rank textd> "direction1"</rank textd>
<reference>
<ref id ="9900m" id1="2000" ref="URL">
</reference>
</country>
</data id>
....
</table1>

</table1 name ="Manager table" name ="E1 Enterprises" refid ="202"
<data id = "ARZ" emp = "dt">
<country id ="m1" name =dt1">
<rank text> "data"</rank text>
<rank textd> "direction"</rank textd>
<reference>
<ref id ="9900m" id1="1000" ref="URL">
</reference>
</country>
<data id = "QNC" emp = "dt1">
<country id ="m2" name =dt2">
<rank text> "data1"</rank text>
<rank textd> "direction1"</rank textd>
<reference>
<ref id ="9900m" id1="2000" ref="URL">
</reference>
</country>
</data id>
....
</table1>
...


Thanks,
Aarush

What I have tried:

I tried element tree , but not to start parsing from table1
Posted
Updated 18-Jun-20 22:26pm
v2

1 solution

You've got 3 elements table1. Use name tag to get proper data.
See:
XML parsing in Python - GeeksforGeeks[^]
How do I parse XML in Python? - Stack Overflow[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900