XML parsing and writing

c00i90wn cooldown at gmail.com
Mon Jul 31 15:36:01 EDT 2006


Nice package ElementTree is but sadly it doesn't have a pretty print,
well, guess I'll have to do it myself, if you have one already can you
please give it to me? thanks :)

Stefan Behnel wrote:
> 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