no line breaks in xml file with elementTree

hackingKK hackingkk at gmail.com
Sun Oct 31 08:15:49 CET 2010


Hello all.
I want to know if there is a way to have the ElementTree module write to 
an xml file with line breaks?
I find that when I use the write function from the module on a tree 
object, the resulting file has no line breaks.  I don't want to use 
prittyprint because it is adding extra tabs to the file and they are 
either counted as extra nodes or in case of element.text with 
elementtree, they are rendered as a part of the text, both being 
impractical results.
So is there a middle approach where we can have some  thing similar to 
prityprint but without the extra tabs and yet having a properly line 
breaked xml file?
Further more, I just was curious why elementtree is not having the 
namespace facility?
xml.dom.minidom has a way to generate tags with namespaces.
Any thing similar in elementTree?

happy hacking.
Krishnakant.






More information about the Python-list mailing list