I am using lxml and I am trying to get the original xml string like this:
>>> elem = etree.fromstring("<tag>áéíóúñü</tag>")
>>> etree.tostring(elem)
b'<tag>áéíóúñü</tag>'
The only way I found to get the source string:
>>> etree.tostring(elem, encoding = "utf-8").decode("utf-8")
'<tag>áéíóúñü</tag>'
Is there a better aproach?
source
share