Witam.
Ostatnio próbowałem odczytywać z pliku xml dane przy pomocy biblioteki pythona minidom
już to kiedyś robiłem zrobiłem praktycznie tak samo i w app którą kiedyś zrobiłem działało to bez problemu ale teraz wyrzuca mi taki błąd:
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 29, column 22
Pełen Trackback:
Traceback (most recent call last):
File "C:/Users/piotr/PycharmProjects/Projekt/Api/DEdit/DEdit/DEdit.pyw", line 304, in <module>
ui.setupUi(MainWindow)
File "C:/Users/piotr/PycharmProjects/Projekt/Api/DEdit/DEdit/DEdit.pyw", line 178, in setupUi
self.read_keywords_from_xml()
File "C:/Users/piotr/PycharmProjects/Projekt/Api/DEdit/DEdit/DEdit.pyw", line 276, in read_keywords_from_xml
xml_doc = minidom.parse(way)
File "C:\Python\lib\xml\dom\minidom.py", line 1958, in parse
return expatbuilder.parse(file)
File "C:\Python\lib\xml\dom\expatbuilder.py", line 911, in parse
result = builder.parseFile(fp)
File "C:\Python\lib\xml\dom\expatbuilder.py", line 207, in parseFile
parser.Parse(buffer, 0)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 29, column 22
I tak nie dokońca rozumiem co jest problemem tu.
Jak mówiłem identycznie miałem w innym programie i działało teraz coś nie chce może ktoś ma pomysł.
Ps. Kod
def read_keywords_from_xml(self):
way = self.find_way_to_file("keywords.xml")
print(way)
xml_doc = minidom.parse(way)
self.xmldata.append([])
# While to takes elements from xml file
for item in xml_doc.getElementsByTagName('keywords')[0].getElementsByTagName("item"):
self.xmldata[0].append(item.attributes["word"].value)
self.xmldata.append([])
for item in xml_doc.getElementsByTagName('operators')[0].getElementsByTagName("item"):
self.xmldata[1].append(item.attributes["symbol"].value)
self.xmldata.append([])
for item in xml_doc.getElementsByTagName('braces')[0].getElementsByTagName("item"):
self.xmldata[2].append(item.attributes["key"].value)
self.xmldata.append([])
for item in xml_doc.getElementsByTagName('function')[0].getElementsByTagName("item"):
self.xmldata[3].append(item.attributes["func"].value)
self.xmldata.append([])