I am using elementtree to write an XML document and I am having a hard
time adding the correct indentation.
I have tried using the indent method, but I can not figure out how to
use it. Any suggestions.
Using the version of indent() found on
http://effbot.org/zone/element-lib.htm:
>>> from xml.etree import ElementTree as ET
>>> x='<a><b /><c /><d>stuff</d><e><f /></e></a>'
>>> e=ET.fromstring(x)
>>> ET.dump(e)
<a><b /><c /><d>stuff</d><e><f /></e></a>
>>> indent(e)
>>> ET.dump(e)
<a>
<b />
<c />
<d>stuff</d>
<e>
<f />
</e>
</a>
-Mark