toprettyxml messes up with whitespaces
Legrandin
kwifturkir at kriocoudek.mailexpire.com
Wed Oct 3 15:46:15 EDT 2007
Hi Jorgen,
> 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.
[ ... ]
> 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.
Before calling toxml/toprettyxml, I strip (with rstrip and lstrip) all
text nodes and take care of removing all the empty ones.
Of course, this is feasible only if whitespace (space, tab, newline) is
not meaningful for the application.
Legrandin
More information about the Python-list
mailing list