0

One xml file has encoding type UTF-16 and another has UTF-8. After taking input of two files I want to parse it together, How to add two encoding type?

tree = ET.parse(xmlFile)
xml_data = tree.getroot()
xmlstr = ET.tostring(xml_data, encoding='utf-8/UTF-16', method='xml')
data_dict = dict(xmltodict.parse(xmlstr))
Nikita
  • 27
  • 1
  • 5
  • You have to realise that having a text with 2 different encodings makes no sense. That's like writing a text that is simultanouesly in English and Chinese. – matszwecja Jul 11 '22 at 07:30
  • No, it is actually a folder that has two different types of encoded xml files. – Nikita Jul 11 '22 at 09:19
  • I'm speaking about this part: `ET.tostring(xml_data, encoding='utf-8/UTF-16', method='xml')`. This has nothing to do with files, whose encoding is decided when you create `xmlFile` object. – matszwecja Jul 11 '22 at 09:43
  • Setting `encoding='utf-8/UTF-16'` won't work. It's just strange. What do you expect to accomplish with something like that? – mzjn Jul 11 '22 at 11:07

0 Answers0