def concat_xml(file_list):
 checksum = hashlib.new('sha1')
 if (not file_list):
  return ('', checksum.hexdigest())
 root = None
 for fname in file_list:
  with open(fname, 'rb') as fp:
   contents = fp.read()
   checksum.update(contents)
   fp.seek(0)
   xml = ElementTree.parse(fp).getroot()
  if (root is None):
   root = ElementTree.Element(xml.tag)
  for child in xml.getchildren():
   root.append(child)
 return (ElementTree.tostring(root, 'utf-8'), checksum.hexdigest())

def concat_xml ( file_list ) : checksum = hashlib . new ( 'sha1' ) if ( not file_list ) : return ( '' , checksum . hexdigest ( ) ) root = None for fname in file_list : with open ( fname , 'rb' ) as fp : contents = fp . read ( ) checksum . update ( contents ) fp . seek ( 0 ) xml = ElementTree . parse ( fp ) . getroot ( ) if ( root is None ) : root = ElementTree . Element ( xml . tag ) for child in xml . getchildren ( ) : root . append ( child ) return ( ElementTree . tostring ( root , 'utf-8' ) , checksum . hexdigest ( ) )
concatenate xml files .