def check_xml(code):
    """Yield errors."""
    try:
        xml.etree.ElementTree.fromstring(code)
    except xml.etree.ElementTree.ParseError as exception:
        message = '{}'.format(exception)
        line_number = 0

        found = re.search(r': line\s+([0-9]+)[^:]*$', message)
        if found:
            line_number = int(found.group(1))

        yield (int(line_number), message)
def check_xml ( code ) : try : xml . etree . ElementTree . fromstring ( code ) except xml . etree . ElementTree . ParseError as exception : message = '{}' . format ( exception ) line_number = 0 found = re . search ( r': line\s+([0-9]+)[^:]*$' , message ) if found : line_number = int ( found . group ( 1 ) ) yield ( int ( line_number ) , message )
Yield errors.