homepage

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.

classification
Title: Add xml pretty print option to ElementTree
Type: enhancement Stage: resolved
Components: Versions: Python 3.8, Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: xml.etree.ElementTree: add feature to prettify XML output
View: 14465
Assigned To: Nosy List: eli.bendersky, rhettinger, scoder
Priority: normal Keywords:

Created on 2015年04月02日 07:01 by rhettinger, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Messages (2)
msg239879 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2015年04月02日 07:01
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))
msg239881 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2015年04月02日 07:08
duplicate of issue 14465 
History
Date User Action Args
2022年04月11日 14:58:15adminsetgithub: 68035
2018年08月17日 15:22:53mceplsetversions: + Python 3.6, Python 3.7, Python 3.8
2015年04月02日 08:20:47serhiy.storchakasetstatus: open -> closed
superseder: xml.etree.ElementTree: add feature to prettify XML output
resolution: duplicate
stage: resolved
2015年04月02日 07:08:34scodersetnosy: + rhettinger
messages: + msg239881
2015年04月02日 07:02:41rhettingersetnosy: + scoder, eli.bendersky, - rhettinger
2015年04月02日 07:01:50rhettingercreate

AltStyle によって変換されたページ (->オリジナル) /