I'm using the lines of code below to prettyprint elementtree object in python 2.7:
xml_str = minidom.parseString(ET.tostring(tgt_xml.getroot())).toprettyxml(indent="\t", encoding='utf-8')
with open(final_path, "w") as f:
f.write(xml_str)
It does it's job, but adds 2 blank lines after each line of xml ... so in result it looks like
<Workflow name="Some_name">
<taskWorkflow>
<taskWorkflow retainSysIds="false">
<variables>
<variable>
<description/>
Does anybody know how to prettyprint elementtree without the blank lines?