Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17140
| From | Stefan Behnel <stefan_ml@behnel.de> |
|---|---|
| Subject | Re: Fixing the XML batteries |
| Date | 2011-12-13 15:59 +0100 |
| References | <jbsfar$en7$1@dough.gmane.org> <CAKmKYaBid4c8Y0pe7txxZMk9+0WN8Hr5ZodS=HP05MdV-ysPhQ@mail.gmail.com> <4EE7425A.2090006@gmail.com> <jc7glm$j62$1@dough.gmane.org> <jc7ndj$5rn$1@dough.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3599.1323788409.27778.python-list@python.org> (permalink) |
Serhiy Storchaka, 13.12.2011 15:27: > 13.12.11 14:32, Stefan Behnel написав(ла): >> I stripped my name from the quoted context because I didn't say this. > > I am glad to hear this. ;) It matches my opinion though. >>> I use xml.dom.minidom for XML canonization and convertion: >> Do you mean "canonicalisation"? I.e. C14N? That's not what the code >> below is doing, not at all. > > No, only converting to certain textual representation. Converting entities > to text (if possible), converting "'" to '"' for quoting, sorting > attributes, etc. Yes, that's what C14N is there for, typically used for cryptography, hashing, etc. However, MiniDOM doesn't implement that standard, so you're on your own here. >>> How to do this with xml.etree.ElementTree? >> In Python 2.7/3.2, ElementTree has support for C14N serialisation, just >> pass the option method="c14n". > > Thanks, I will try this. But I need 2.6+ compatibility. The ET module is actually quite short (<1700 lines), so you can just copy the Py2.7 version into your sources and optionally import it on older Python releases. Since you only seem to depend on the serialiser (which is worth using anyway because it is much faster in the Py2.7 version), older platform versions of cET should also work just fine with that module copy, so you can basically just import everything from xml.etree.cElementTree and use the ElementTree class and the tostring() function from your own local version if the platform version is too old. Note that ET is also still available as a separately installable package, may or may not be simpler to use for you. Stefan
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Fixing the XML batteries Stefan Behnel <stefan_ml@behnel.de> - 2011-12-13 15:59 +0100
csiph-web