XML parsing and writing

Stefan Behnel stefan.behnel-n05pAM at web.de
Mon Jul 31 05:10:29 EDT 2006


c00i90wn wrote:
> Hey, I'm having a problem with the xml.dom.minidom package, I want to
> generate a simple xml for storing configuration variables, for that
> purpose I've written the following code, but before pasting it I'll
> tell you what my problem is. On first write of the xml everything goes
> as it should but on subsequent writes it starts to add more and more
> unneeded newlines to it making it hard to read and ugly.

Maybe you should try to get your code a little cleaner first, that usually
helps in finding these kinds of bugs. Try rewriting it with ElementTree or
lxml, that usually helps you in getting your work done.

http://effbot.org/zone/element-index.htm
http://codespeak.net/lxml/

Stefan



More information about the Python-list mailing list