I use lxml.objectify to easily parse and work with an XML file. For auditing reasons, I have to save a derived object together with the originating XML code of the element.
root = lxml.objectify.fromstring(self.get_xml_data())
for i, elem in enumerate(root.elements):
# create new database entry based on elem
elem_obj.source_code = turn_elem_into_xml(elem)
How could I implement turn_elem_into_xml?
lxml.etree.tostring