toprettyxml messes up with whitespaces

Jorgen Bodde jorgen.maillist at gmail.com
Tue Oct 2 12:43:37 EDT 2007


Hi all,

I parse an XML file, replace a node with a new one (like updating
cache) and write it back. Every write, new spaces are added. For
example, first read - update - write cycle;

<var name="APPNAME" status="undefined">
     My First App								
</var>

Second cycle:

<var name="APPNAME" status="undefined">
                 My First App								
</var>

Third cycle:

<var name="APPNAME" status="undefined">
                                           My First App								
</var>


And this goes on. The node is one that is not touched in the XML, it
is simply written back after reading. I have the same with void spaces
in between the nodes, I managed to compensate that by stripping the
lines.

I would like to use toprettyxml to make it user editable and viewable.
But this is really weird. How can I circumvent this behaviour?

regards,
- Jorgen



More information about the Python-list mailing list