Parse XML in Python with encoding other than utf-8
问题 Any clue on how to parse xml in python that has: encoding='Windows-1255' in it? At least the lxml.etree parser won't even look at the string when there's an "encoding" tag in the XML header which isn't "utf-8" or "ASCII". Running the following code fails with: ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration. from lxml import etree parser = etree.XMLParser(encoding='utf-8') def convert_xml_to_utf8(xml_str):