def parse(filename, return_doctype_dict=False):
doctype_dict = {}<EOL>if sys.version_info < (<NUM_LIT:3>,<NUM_LIT:2>):<EOL><INDENT>parser = CustomXMLParser(html=<NUM_LIT:0>, target=None, encoding='<STR_LIT:utf-8>')<EOL><DEDENT>else:<EOL><INDENT>tree_builder = CustomTreeBuilder()<EOL>parser = ElementTree.XMLParser(html=<NUM_LIT:0>, target=tree_builder, encoding='<STR_LIT:utf-8>')<EOL><DEDENT>tree = ElementTree.parse(filename, parser)<EOL>root = tree.getroot()<EOL>if sys.version_info < (<NUM_LIT:3>,<NUM_LIT:2>):<EOL><INDENT>doctype_dict = parser.doctype_dict<EOL><DEDENT>else:<EOL><INDENT>doctype_dict = tree_builder.doctype_dict<EOL><DEDENT>if return_doctype_dict is True:<EOL><INDENT>return root, doctype_dict<EOL><DEDENT>else:<EOL><INDENT>return root<EOL><DEDENT>
to extract the doctype details from the file when parsed and return the data
for later use, set return_doctype_dict to True