XML2Dict
XML2Dict copied to clipboard
Parse Error when first line is blank
Hi. parse error is thrown when first line is blank or is comment the xml content:
<!-- first line is blank or have a comment, like this one -->
<?xml version="1.0" encoding="UTF-8"?>
<rss>
<item>foo</item>
<item>bar</item>
<item>baz</item>
</rss>
the error:
File "/usr/local/lib/python3.8/dist-packages/encoder.py", line 93, in parse
EL = ET.fromstring(xml)
File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1320, in XML
parser.feed(text)
xml.etree.ElementTree.ParseError: XML or text declaration not at start of entity: line 2, column 0
Removing the blank line or comment solves the problem.
Regards.