xml.etree.ElementTree.tostring(element, encoding="us-ascii", method="xml", *, short_empty_elements=True)Generates a string representation of an XML element, including all subelements. element is an Element instance. encoding [1] is the output encoding (default is US-ASCII). Use encoding="unicode" to generate a Unicode string (otherwise, a bytestring is generated). method is either "xml", "html" or "text" (default is "xml"). short_empty_elements has the same meaning as in ElementTree.write(). Returns an (optionally) encoded string containing the XML data.
Traceback (most recent call last):File "/Users/todd.wells/Dropbox/thePlatform SA/aws/lambda-ingest-proxy/modify-title-handler/test_modify_title_handler.py", line 11, in test_modify_titlemodified = handler.lambda_handler(event, None)File "/Users/todd.wells/Dropbox/thePlatform SA/aws/lambda-ingest-proxy/modify-title-handler/modify_title_handler.py", line 17, in lambda_handlerevent['body'] = ET.tostring(root, encoding='text', method='xml')File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/xml/etree/ElementTree.py", line 1135, in tostringshort_empty_elements=short_empty_elements)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/xml/etree/ElementTree.py", line 759, in writewith _get_writer(file_or_filename, enc_lower) as write:File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 82, in __enter__return next(self.gen)File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/xml/etree/ElementTree.py", line 831, in _get_writernewline="\n")LookupError: unknown encoding: text