[lxml-dev] c14n, pretty printing and diffing

Stefan Behnel stefan_ml at behnel.de
Mon Feb 11 19:56:28 CET 2008


Hi,

Olivier Collioud wrote:
> I would like to use my favourite text diffing tool to compare XML
> files.

Which is not lxml.html.diff, I assume? (I'm not sure how HTML specific that
is, BTW). Also, for doctests, there is lxml.usedoctest that you can import
(the lxml web pages use it for doctests).


> Is their a way to produce a pretty printed canonical version of my XML
> files using lxml ?

Not using the c14n interface (libxml2 doesn't support it). Serialising by hand
is not too hard, though. You can look at ElementTree._write() for an example:

http://svn.effbot.org/public/elementtree/elementtree/ElementTree.py

Stefan



More information about the lxml-dev mailing list