I've looked at: Pretty printing XML in Python This doesn't suit my needs, because for various reasons - I've got a base install of Python 3.2 on Windows, but no ability to add modules. (user privs).
The suggested solution is:
import xml.dom.minidom
xml = xml.dom.minidom.parse(xml_fname)
pretty_xml_as_string = xml.toprettyxml()
This turns:
<root>
<node>content</node>
<node attrib="value">more content</node>
</root>
Into:
<?xml version="1.0" ?>
<root>
<node>content</node>
<node attrib="value">more content</node>
</root>
It does work if you've got:
<root><node>content</node><node attrib="value">more content</node></root>
So I would assume it's preserving linefeeds, but adding extra indent/whitespace. I appreciate the answer is probably 'use a module' - but what I'm looking for is something that can turn arbitrary formatted xml
into consistently pretty-printed.
(And using a core install module if at all possible).