def asXML(self, encoding="utf-8"): xml_tree = self.asXMLTree() xml_string = ET.tostring(xml_tree, encoding) return xml_beautifier(xml_string)