← 输入框|github.com|刷新
Skip to content

Add xml pretty print option to ElementTree #68035

Closed

Description

@rhettinger
BPO 23847
Nosy @rhettinger, @scoder
Superseder
  • bpo-14465: xml.etree.ElementTree: add feature to prettify XML output
  • 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 2015-04-02.08:20:47.244>
    created_at = <Date 2015-04-02.07:01:50.309>
    labels = ['3.8', 'type-feature', '3.7']
    title = 'Add xml pretty print option to ElementTree'
    updated_at = <Date 2018-08-17.15:22:53.057>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2018-08-17.15:22:53.057>
    actor = 'mcepl'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-04-02.08:20:47.244>
    closer = 'serhiy.storchaka'
    components = []
    creation = <Date 2015-04-02.07:01:50.309>
    creator = 'rhettinger'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 23847
    keywords = []
    message_count = 2.0
    messages = ['239879', '239881']
    nosy_count = 3.0
    nosy_names = ['rhettinger', 'scoder', 'eli.bendersky']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '14465'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue23847'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7', 'Python 3.8']

    Activity

    1. rhettinger commented on Apr 2, 2015

      @rhettinger
      ContributorAuthor

      The xml.dom.minidom package has as a xml.toprettyxml() function that has the problem of altering the whitespace of the text of elements. The ElementTree module needs a prettify option that works better, perhaps something based of Effbot's code at:

      http://effbot.org/zone/element-lib.htm#prettyprint

      The lxml package also provides an API for this purpose:

          print(etree.tostring(root, pretty_print=True))
    2. scoder commented on Apr 2, 2015

      @scoder
      Contributor

      duplicate of bpo-14465

    3. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions