0

I am trying to parse a large xml file (more than 50mb). Getting the following parsing error. File attached for reference. File

import xml.etree.cElementTree as ET
tree = ET.parse('input_file.xml')

error
 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 598, in parse
    self._root = parser._parse_whole(source)

  File "<string>", line unknown
ParseError: no element found: line 21, column 0
3
  • 1
    The obvious answer is that the file does indeed have an error. The error message even helpfully points out the line number. Have you inspected the file to see for yourself? Commented Sep 23, 2019 at 14:06
  • @Ahmad Hasnain, please add XML code of line 20 to 30 Commented Sep 23, 2019 at 14:32
  • Thanks for the answer. The file is too big and unable to load in the browser. Commented Sep 23, 2019 at 22:44

1 Answer 1

1

Your XML is not well-formed, ElementTree cannot parse it. Please take look at your XML file and check whether it has a proper closing tag, maybe special characters and other stuff.

Sign up to request clarification or add additional context in comments.

2 Comments

The file is too big to be opened and inspected in a browser. None of the free xml parsers could load it either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.