#!/usr/bin/env pythonimportosfromosimportpathasospimportxml.etree.ElementTreeasETDIR="xml"OUTPUT="report.xml"defmain():ifosp.isfile(OUTPUT):os.remove(OUTPUT)xml_files=os.listdir(DIR)xml_files=[osp.join(DIR,f)forfinxml_filesiff.endswith(".xml")]# take the first file as basetree_base=ET.parse(xml_files[0])root_base=tree_base.getroot()os.remove(xml_files[0])# iterate over other files and extract errorsforxml_fileinxml_files[1:]:tree=ET.parse(xml_file)root=tree.getroot()forerrorinroot.findall("errors")[0].findall("error"):root_base.findall("errors")[0].append(error)os.remove(xml_file)tree_base.write(OUTPUT)if__name__=='__main__':main()