Hi,
Maybe you have an idea what could be happening here, otherwise I will
(try to) come back with a more complete example. For now I have this
small code excerpt that behaves strangely: (isinstance(output_xml,
lxml.etree._Element) is True)
# The two ET.tostring() invocations below, (1) and (2), show the
# following behaviour:
# (1) "works" (UnicodeDecodeError about el.text after (2))
# (1) (2) "works" (UnicodeDecodeError about el.text after (2))
# (2) does not work, lxml.etree.SerialisationError: IO_ENCODER about
ET.tostsring() (2)
ET.tostring(output_xml) # (1)
# Make pretty-printing work by removing unnecessary whitespace:
for el in output_xml.iter():
ET.tostring(el) # (2)
if len(el) and el.text and not el.text.strip():
el.text = None
if el.tail and not el.tail.strip():
el.tail = None
(1) and (2) are commented out to run them in the different combinations
discussed. If you have a hint about what might be the issue there, I'd
be very glad to hear it. I'm using this code on WinXP SP3, Python
2.6.4, lxml 2.2.2 (pre-compiled package). Expected behaviour would be
to run without raising any exception in any of the runs. Something
about output_xml changed, as this code snipped used to work.
Thanks,
Felix