python ElementTree美化格式

ElementTree生成的xml都在一行,对于程序或者传输来说非常好,但十分不便于阅读,毕竟有些xml是需要人来维护的,那么格式就需要美化了。

text、tail

These attributes can be used to hold additional data associated with the element. Their values are usually strings but may be any application-specific object. If the element is created from an XML file, the text attribute holds either the text between the element’s start tag and its first child or end tag, or None, and the tail attribute holds either the text between the element’s end tag and the next tag, or None. For the XML data

the a element has None for both text and tail attributes, the b element has text"1" and tail"4", the c element has text"2" andtailNone, and the d element has textNone and tail"3".

 

发表评论