Message300673
When trying to generate an XML file with 'xml.etree.ElementTree', there is no way to specify a doctype (example below).
The 'xml.etree.ElementTree.ElementTree.write' method has a 'xml_declaration' flag, which can be used as workaround, but there is no such flag for 'xml.etree.ElementTree.tostring' (and it is not always desirable to write the XML document directly to file). Please compare the corresponding flags in lxml.
Here is an example for a document I would like to generate and convert to string:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><body>text</body></html> |
|
Date |
User |
Action |
Args |
2017-08-22 08:01:08 | bastik | set | recipients:
+ bastik |
2017-08-22 08:01:08 | bastik | set | messageid: <1503388868.57.0.0239596264981.issue31256@psf.upfronthosting.co.za> |
2017-08-22 08:01:08 | bastik | link | issue31256 messages |
2017-08-22 08:01:08 | bastik | create | |
|