Открыть xml-файлы в python с плохим представлением
У меня 100 файлов формата xml, которые я не могу открыть
Пример файла:
<?xml version="1.0" <?xml version="1.0" encoding="UTF-8"?>
<api version="3.2">
<peoplecount>
<entry id="1" name="" userid="">
<count datetime="2022.07.11 14:16:20" realin="0" realout="1" realpass="0" queuetime="0" />
<count datetime="2022.07.11 14:21:57" realin="0" realout="1" realpass="0" queuetime="0" />
<count datetime="2022.07.11 14:23:11" realin="0" realout="1" realpass="0" queuetime="0" />
%skipzero[1,2]%</entry>
</peoplecount>
<timezone name="Europe/Moscow" offset="10800"/>
</api>
Я использую xml.etree.ElementTree для парсинга файла
import xml.etree.ElementTree as ET
tree = ET.parse('pathname.xml')
root = tree.getroot()
for child in root.iter('count'):
print(child.tag, child.attrib)
Ошибка связана с "not well-formed"
Я знаю причину ошибки (In the beginning, you need to delete '<?xml version="1.0" ') , но так как файлов более 100, устану открывать каждый и удалять
Есть идеи, как поправить формат файла перед открытием?