Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml.etree.ElementTree: add support for doctype in tostring method #75439

Closed
bastik mannequin opened this issue Aug 22, 2017 · 5 comments
Closed

xml.etree.ElementTree: add support for doctype in tostring method #75439

bastik mannequin opened this issue Aug 22, 2017 · 5 comments
Labels
3.8 only security fixes topic-XML type-feature A feature request or enhancement

Comments

@bastik
Copy link
Mannequin

bastik mannequin commented Aug 22, 2017

BPO 31256
Nosy @scoder, @codeape2, @iritkatriel
PRs
  • bpo-36227: ElementTree.tostring() default_namespace argument #12225
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-10-01.08:04:49.618>
    created_at = <Date 2017-08-22.08:01:08.489>
    labels = ['expert-XML', 'type-feature', '3.8']
    title = 'xml.etree.ElementTree: add support for doctype in tostring method'
    updated_at = <Date 2021-08-15.22:46:41.105>
    user = 'https://bugs.python.org/bastik'

    bugs.python.org fields:

    activity = <Date 2021-08-15.22:46:41.105>
    actor = 'sucharik'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-10-01.08:04:49.618>
    closer = 'scoder'
    components = ['XML']
    creation = <Date 2017-08-22.08:01:08.489>
    creator = 'bastik'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31256
    keywords = ['patch']
    message_count = 5.0
    messages = ['300673', '337479', '377718', '377742', '399629']
    nosy_count = 5.0
    nosy_names = ['scoder', 'Bernt.R\xc3\xb8skar.Brenna', 'bastik', 'iritkatriel', 'sucharik']
    pr_nums = ['12225']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue31256'
    versions = ['Python 3.8']

    @bastik
    Copy link
    Mannequin Author

    bastik mannequin commented Aug 22, 2017

    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>

    @bastik bastik mannequin added topic-XML type-feature A feature request or enhancement labels Aug 22, 2017
    @codeape2
    Copy link
    Mannequin

    codeape2 mannequin commented Mar 8, 2019

    See also: https://bugs.python.org/issue36227

    PR: #12225

    @iritkatriel
    Copy link
    Member

    It looks like PR 12225 resolved this issue. Can this be closed then?

    @scoder
    Copy link
    Contributor

    scoder commented Oct 1, 2020

    Yes, it fixed already. Thanks!

    @scoder scoder closed this as completed Oct 1, 2020
    @sucharik
    Copy link
    Mannequin

    sucharik mannequin commented Aug 15, 2021

    May I aks, how it to add a doctype now?

    @sucharik sucharik mannequin added the 3.8 only security fixes label Aug 15, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes topic-XML type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants