1

In Python 3, I need to Canonicalize (c14n) an XML string.

Which module/package can I use for this? And how should I do this?

For reference: http://www.w3.org/TR/xml-exc-c14n/

Miguel Carvalhais Matos
  • 1,113
  • 2
  • 13
  • 21

1 Answers1

2

Simplest would probably be:

https://lxml.de/api/lxml.etree-module.html#tostring

This function takes method='c14n', exclusive and with-comments which all are c14n canonicalization related.

It is not perfect but would get your 90% there... you would still want to manually check things.

Next a little less pythonic would be libxml2... though in my very limited experience with it is even more tricky.

k1m190r
  • 1,213
  • 15
  • 26