The python2 equivalent of html.entities is htmllib.entitydefs (https://docs.python.org/2/library/htmllib.html#module-htmlentitydefs).

On 13 May 2018 at 13:15, Thomas Levine <_@thomaslevine.com> wrote:
Peng Yu writes:
> I just realize that tostring() makes changes to symbols like =C2=B0. If I
> just to strip the outermost tag, without changing anything to the
> internal text. How to do it? Thanks.
>
> from lxml import etree
> tree =3D etree.XML('<foo>25/15=C2=B0C <bar>abc</bar></foo>')
> print etree.tostring(tree)
>
> The output of the above code is the following.
>
> <foo>25/15&#176;C <bar>abc</bar></foo>

Check the lxml documentation for a way to run tostring without XML/HTML
entities. Alternatively, replace them afterwards; I don't think it's in
Python 2, but the module html.entities may be helpful.
_________________________________________________________________
Mailing list for the lxml Python XML toolkit - http://lxml.de/
lxml@lxml.de
https://mailman-mail5.webfaction.com/listinfo/lxml