Hello.
Is there any reason why attributes of Element returned as bytestring
if only contains ascii?
In my application i need it to be unicode always.
Is there a way to force lxml return element attribute as unicode?
What is the preferred way of getting attributes as unicode?
1.
value = elem.attrib['foo']
if isinstance(value, str):
encoding = elem.getroottree().docinfo.encoding
value = value.decode(encoding)
2.
value = elem.attrib['foo']
if isinstance(value, str):
value = value.decode('ascii')
--
--------------------------------------------
Турнаев Евгений Викторович
+7 906 875 09 43
--------------------------------------------