I am using SQLite to access a database and retrieve the desired information. I\'m using ElementTree in Python version 2.6 to create an XML file with tha
If one wants to use lxml, it could be done in the following way:
from lxml import etree
xml_object = etree.tostring(root,
pretty_print=True,
xml_declaration=True,
encoding='UTF-8')
with open("xmlfile.xml", "wb") as writter:
writter.write(xml_object)`
If you see xml namespaces e.g. py:pytype="TREE", one might want to add before the creation of xml_object
etree.cleanup_namespaces(root)
This should be sufficient for any adaptation in your code.