def read_xml(filename):
parser = et.XMLParser(remove_blank_text=True)<EOL>isfile=False<EOL>try:<EOL><INDENT>isfile = os.path.exists(filename)<EOL><DEDENT>except ValueError as e:<EOL><INDENT>if '<STR_LIT>' in str(e):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>try:<EOL><INDENT>if isfile:<EOL><INDENT>return et.parse(filename, parser)<EOL><DEDENT>else:<EOL><INDENT>r = et.fromstring(filename, parser)<EOL>return r.getroottree()<EOL><DEDENT><DEDENT>except IOError:<EOL><INDENT>log.exception('<STR_LIT>'.format(filename))<EOL><DEDENT>except et.XMLSyntaxError:<EOL><INDENT>log.exception('<STR_LIT>'.format(filename))<EOL>return None<EOL><DEDENT>return None<EOL>
Use et to read in a xml file, or string, into a Element object.

:param filename: File to parse.
:return: lxml._elementTree object or None