[lxml-dev] Forced attribute value escaping

Stefan Behnel stefan_ml at behnel.de
Fri Jun 6 13:20:39 CEST 2008


Hi,

please keep the list in CC.

RommeDeSerieux wrote:
> #! /usr/bin/env python
> ## vim: fileencoding=utf-8
> from lxml import etree
> 
> node = etree.Element(u'tag_тег')
> node.attrib[u'attribute_атрибут'] = u'value_значение'
> node.text = u'text_текст'
> 
> # what i'm getting (with some linebreaks for email):
> # <tag_тег attribute_атрибут="value_&#x437;&#x43D;&#x430;
> # &#x447;&#x435;&#x43D;&#x438;&#x435;">text_текст
> # </tag_тег>
> #
> # expected result:
> # <tag_тег attribute_атрибут="value_значение">text_текст
> # </tag_тег>
> print etree.tostring(node, encoding='utf-8')

Yep, the serialisation is done by libxml2, so if you feel that this should
look different, please file a bug report over there, or report it on their
mailing list.

http://xmlsoft.org/bugs.html

Stefan


More information about the lxml-dev mailing list