2015-03-11 16:28 GMT+01:00 Omar Gutiérrez <omar.vpa@gmail.com>:
How can I escape it if I need to do it?
Do you need it because the data is parsed by a non-compliant XML parser, or do you need it because the data is then embedded in another context (like a SQL sentence)?
My solution at this moment is to use tostring() to save the file and after that apply a replace, nevertheless, I think is a bad and dirty solution, because I need to add the XML's header <?xml version='1.0' encoding='UTF-8'?> with hardcoding.
On Wed, Mar 11, 2015 at 2:34 AM, Amaury Forgeot d'Arc <amauryfa@gmail.com> wrote:
2015-03-10 20:47 GMT+01:00 Omar Gutiérrez <omar.vpa@gmail.com>:
I was wondering why the apostrophe is not automatically escaped as other characters?
Because it's not needed? See https://wiki.python.org/moin/EscapingXml for a similar discussion.
For example:
< is transformed to *<*
and
is transformed to *>* but ' is not transformed to *'*
Python : sys.version_info(major=2, minor=7, micro=6, releaselevel='final', serial=0)
lxml.etree : (3, 3, 3, 0) libxml used : (2, 9, 1) libxml compiled : (2, 9, 1) libxslt used : (1, 1, 28) libxslt compiled : (1, 1, 28)
_________________________________________________________________ Mailing list for the lxml Python XML toolkit - http://lxml.de/ lxml@lxml.de https://mailman-mail5.webfaction.com/listinfo/lxml
-- Amaury Forgeot d'Arc
-- Amaury Forgeot d'Arc