17 Mar
2011
17 Mar
'11
10:17 a.m.
Hi, there is a strange behavior, if im trying to use the 'xml_declaration' parameter on unicode encoding:
from lxml import etree root = etree.Element("root") res = etree.tostring(root, encoding="unicode", xml_declaration=True)
raises: Traceback (most recent call last): File "<pyshell#1>", line 4, in <module> res = etree.tostring(root, encoding="unicode", xml_declaration=True) File "lxml.etree.pyx", line 2838, in lxml.etree.tostring (src/lxml/lxml.etree.c:53452) ValueError: Serialisation to unicode must not request an XML declaration I don't understand why it is not allowed to control the xml declaration if i'm using unicode. My environment is lxml 2.3.0 on CPython 2.7.1 (WinXP 32bit) Thanks in advance, Daniel