Artem: That version will silence all legitimate XMLSyntaxErrors too, though.
yli: That's true, although it's easy to work around that by using a guard instead:
for (state, elem) in etree.iterparse(f): if elem.tag == 'foo': [...process...]
# Work around bug #1185701 by bailing out after the end of the document root. if elem.getparent() is None: break
Artem: That version will silence all legitimate XMLSyntaxErrors too, though.
yli: That's true, although it's easy to work around that by using a guard instead:
for (state, elem) in etree.iterparse(f):
[. ..process. ..]
if elem.tag == 'foo':
# Work around bug #1185701 by bailing out after the end of the document root.
if elem.getparent() is None:
break