diff --git a/comicapi/comicinfoxml.py b/comicapi/comicinfoxml.py index d6a307b..d9b724a 100644 --- a/comicapi/comicinfoxml.py +++ b/comicapi/comicinfoxml.py @@ -51,12 +51,9 @@ class ComicInfoXml: return self.convertXMLToMetadata(tree) def stringFromMetadata(self, metadata, xml=None): - - header = '\n' - tree = self.convertMetadataToXML(self, metadata, xml) - tree_str = ET.tostring(tree.getroot()).decode() - return header + tree_str + tree_str = ET.tostring(tree.getroot(), encoding="utf-8", xml_declaration=True).decode() + return tree_str def indent(self, elem, level=0): # for making the XML output readable @@ -90,7 +87,6 @@ class ComicInfoXml: def assign(cix_entry, md_entry): if md_entry is not None: - print(cix_entry, md_entry) et_entry = root.find(cix_entry) if et_entry is not None: et_entry.text = "{0}".format(md_entry) @@ -278,7 +274,7 @@ class ComicInfoXml: tree = self.convertMetadataToXML(self, metadata, xml) # ET.dump(tree) - tree.write(filename, encoding='utf-8') + tree.write(filename, encoding="utf-8", xml_declaration=True) def readFromExternalFile(self, filename):