[New-bugs-announce] [issue31256] xml.etree.ElementTree: add support for doctype in tostring method

bastik report at bugs.python.org
Tue Aug 22 04:01:08 EDT 2017


New submission from bastik:

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>

----------
components: XML
messages: 300673
nosy: bastik
priority: normal
severity: normal
status: open
title: xml.etree.ElementTree: add support for doctype in tostring method
type: enhancement
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31256>
_______________________________________


More information about the New-bugs-announce mailing list