How can I escape it if I need to do it?

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 &lt;

and

> is transformed to &gt;

but ' is not transformed to &apos;


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