Problem In Parsing The Xml File: Xml.etree.elementtree.parseerror: Not Well-formed (invalid Token): Line 19, Column 175
I need to parse an XML file with multiple roots but I am unable to read the file. I get an error Traceback (most recent call last): File 'C:/Users/Abhi/PycharmProjects/Trec_proj
Solution 1:
If it has multiple roots then it's not an XML file. Or at least, to be technical, it's not a well-formed XML document entity.
It is however a well-formed XML external parsed entity, and that gives you a workaround. In fact it gives you a choice of two:
(a) read the contents of the file as a string, wrap it in a new outermost element ("<z>" + content + "</z>"
) and then parse that
(b) write a wrapper document that references the document as an external entity, and parse the wrapper document:
<!DOCTYPE z [
<!ENTITY e SYSTEM"content.xml">
]><z>&e;</z>
Post a Comment for "Problem In Parsing The Xml File: Xml.etree.elementtree.parseerror: Not Well-formed (invalid Token): Line 19, Column 175"