This line in a python script:
result = xmltodict.parse('path/to/schema.xml', encoding='utf-8')
generates this error:
johnnyb@verahost ~/SignalDB $ python3 xmltest.py
Traceback (most recent call last):
File "xmltest.py", line 13, in <module>
result = xmltodict.parse('path/to/schema.xml', encoding='utf-8')
File "/home/johnnyb/.local/lib/python3.5/site-packages/xmltodict.py", line 330, in parse
parser.Parse(xml_input, True)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 8
The first line of the file is:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
What am I missing? Note: the BOM at the beginning does not show up via head at the linux command line (above text is from Win10). Suggestions welcome! Never had to monkey with XML before, my luck ended today...
EDIT: I was able to get around it by open()ing the file first, but this seems like it should be unnecessary?
with open('path/to/schema.xml', 'r', encoding='utf-8') as fd:
result = xmltodict.parse(fd.read())