I am a beginner in Python. I use Python 2.7 with ElementTree to parse XML files. I have a big XML file (~700 MB), which contains multiple root instances, for example:
<?xml version="1.0" ?> <foo> <bar> <sometag> Mehdi </sometag> <someothertag> blahblahblah </someothertag> . . . </bar> </foo>
<?xml version="1.0" ?> <foo> <bar> <sometag> Hamidi </sometag> <someothertag> blahblahblah </someothertag> . . . </bar> </foo>
...
...
each xml instance is placed in one line. I need to parse such file in python. I used ElementTree this way:
import xml.etree.ElementTree as ET
tree = ET.parse('filename.xml')
root = tree.getroot()
but it seems it just can access to the first root XML instance line. What is the proper way to parse all XML instances in this type of file?