ordering the Xml

25 浏览
0 Comments

ordering the Xml

有哪些最佳方法来(或者说有哪些方法)在Python中美化打印XML?

admin 更改状态以发布 2023年5月24日
0
0 Comments

是最近更新的,包括了一个漂亮的打印功能

import lxml.etree as etree
x = etree.parse("filename")
print etree.tostring(x, pretty_print=True)

查看教程:
http://lxml.de/tutorial.html

0
0 Comments
import xml.dom.minidom
dom = xml.dom.minidom.parse(xml_fname) # or xml.dom.minidom.parseString(xml_string)
pretty_xml_as_string = dom.toprettyxml()

的中文意思是:粗体字的123。

0