code: def etree_to_string(tree):
          
          buff = BytesIO()
          tree.write(buff, xml_declaration=True, encoding='UTF-8')
          return buff.getvalue()
docs: Creates string from lxml.etree.ElementTree with XML declaration and UTF-8 encoding.
  
          :param tree: the instance of ElementTree
          :return: the string of XML.