7 Feb
2007
7 Feb
'07
6:54 p.m.
Hi, Narayan Desai wrote:
I seem to recall that Lxml used to raise an exception if binary data was put into a text node of an xml element. Was this change intentional? Is there any way to use lxml to check for document well-formedness before sending out xml?
With 'binary' you mean 'containing 0-bytes', right? It looks like we have a general problem with passing such strings to libxml2:
from lxml.etree import * r = XML("<test/>") r.text = "a\0b" print repr(tostring(r)) a
I guess it would be better to just raise an exception in this case, however, that would require us to walk through all characters of strings that we get passed. Not sure it's worth it. Any comments? Stefan