This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bastik
Recipients bastik
Date 2017-08-22.08:01:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1503388868.57.0.0239596264981.issue31256@psf.upfronthosting.co.za>
In-reply-to
Content
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>
History
Date User Action Args
2017-08-22 08:01:08bastiksetrecipients: + bastik
2017-08-22 08:01:08bastiksetmessageid: <1503388868.57.0.0239596264981.issue31256@psf.upfronthosting.co.za>
2017-08-22 08:01:08bastiklinkissue31256 messages
2017-08-22 08:01:08bastikcreate