I'm trying to parse an xml document that has a number of undefined entities that cause a ParseError when I try to run my code, which is as follows:
import xml.etree.ElementTree as ET
tree = ET.parse('cic.fam_lat.xml')
root = tree.getroot()
while True:
try:
for name in root.iter('name'):
print(root.tag, name.text)
except xml.etree.ElementTree.ParseError:
pass
for name in root.iter('name'):
print(name.text)
An example of said error is as follows, and there are a number of undefined entities that will all throw the same error:
I just want to ignore them rather than go in and edit out each one. How should I edit my exception handling to catch these error instances? (i.e., what am I doing wrong?)