python how to know which tag exactly is not closed in xml
Question: I have an xml, and I validate if it is really a good formatted xml like this:

    
    
    try:
                self.doc=etree.parse(attributesXMLFilePath)
            except IOError:
                error_message = "Error: Couldn't find attribute XML file path {0}".format(attributesXMLFilePath)
                raise XMLFileNotFoundException(error_message)
            except XMLSyntaxError:
                error_message = "The file {0} is not a good XML file, recheck please".format(attributesXMLFilePath)
                raise NotGoodXMLFormatException(error_message)
    

as you see, I am catching the XMLSyntaxError, which is an error from :

`from lxml.etree import XMLSyntaxError`

that works good, but that just told me if the file is not a good xml format.
However, i want to ask you guys if there is a way to know which tag is wrong
because in my situation when i do this:

    
    
    <name>Marco</name1>
    

i got the error, is there a way to know that `name` tag hasn't been closed
yet?

### Update

after some people give me the idea of line and position,i came up with this
code:

    
    
        class XMLFileNotFoundException(GeneralSpiderException):
            def __init__(self, message):
                super(XMLFileNotFoundException, self).__init__(message, self)
    
    class GeneralSpiderException(Exception):
        def __init__(self, message, e):
            super(GeneralSpiderException, self).__init__(message+" \nline of Exception = {0}, position of Exception = {1}".format(e.lineno, e.position))
    

and i am still raising the error like this

    
    
    raise XMLFileNotFoundException(error_message)
    

i got this error now

    
    
        super(GeneralSpiderException, self).__init__(message+" \nline of Exception = {0}, position of Exception = {1}".format(e.lineno, e.position))
    exceptions.AttributeError: 'XMLFileNotFoundException' object has no attribute 'lineno'
    


Answer: You can print the details of the error. For instance:

    
    
    try:
        self.doc = etree.parse(attributesXMLFilePath)
    except XMLSyntaxError as e:
        error_message = "The file {0} is not correct XML, {1}".format(attributesXMLFilePath, e.msg)
        raise NotGoodXMLFormatException(error_message)
    

