I'm currently using the toprettyxml() function of the xml.dom module in a python script and I have some troubles with the newlines.
If don't use the newl parameter or if I use toprettyxml(newl='\n') actually it displays several new lines instead of only one.
f = open(filename, 'w')
<param name="Level" value="#LEVEL#"/>
<param name="Code" value="281"/>
toprettyxml() is quite awful. It is not a matter of Windows and '\r\n'. Trying any string as the
newlparameter shows that too many lines are being added. Not only that, but other blanks (that may cause you problems when a machine reads the xml) are also added.
Some workarounds available at