Iteratively parse a large XML file without using the DOM approach
I have an xml file <temp> <email id="1" Body="abc"/> <email id="2" Body="fre"/> . . <email id="998349883487454359203" Body="hi"/> </temp> I want to read the xml file for each email tag. That is, at a time I want to read email id=1..extract body from it, the read email id=2...and extract body from it...and so on I tried to do this using DOM model for XML parsing, since my file size is 100 GB..the approach does not work. I then tried using: from xml.etree import ElementTree as ET tree=ET.parse('myfile.xml') root=ET.parse('myfile.xml').getroot() for i in root.findall('email/'): print i.get('Body'