Comment 6 for bug 1185701

Revision history for this message
Artem Korzhenevskiy (azurlay) wrote :

Another workaround:

content = etree.iterparse(open(file_path, 'rb'), tag='my_tag')
while True:
    try:
        event, elem = content.next()
        # process element
        yield result
    except (etree.XMLSyntaxError, StopIteration):
        break
del content

The error raises at the end of the file therefore all elements are successfully processed.