2012-01-31 4 views

답변

4

사용 toprettyxml 또는 toxml 방법 : 예를 들어

elt.toprettyxml(indent = ' ') 

,

import xml.dom.minidom as minidom 
doc = minidom.Document() 
foo = doc.createElement("foo") 
doc.appendChild(foo) 
print(foo.__class__) 
# xml.dom.minidom.Element 

print(foo.toprettyxml(indent = ' ')) 
# <foo/> 
관련 문제