I wanted to parse a fairly huge xml-like file which doesn\'t have any root element. The format of the file is:
ElementTree.fromstringlist accepts an iterable (that yields strings).
Using it with itertools.chain:
import itertools
import xml.etree.ElementTree as ET
# import xml.etree.cElementTree as ET
with open('xml-like-file.xml') as f:
it = itertools.chain('', f, ' ')
root = ET.fromstringlist(it)
# Do something with `root`
root.find('.//tag3')