Reputation: 364
Let us suppose. I have xml data, which is not well-formed. Can I print own message like:
xml is not well performed
.
python code
import xml.etree.ElementTree as ET
root = ET.parse('data.xml').getroot()
# ParseError: mismatched tag: line 8, column 26
print('xml is not well performed')
Upvotes: 0
Views: 87
Reputation: 396
try this:
import xml.etree.ElementTree as ET
try:
root = ET.parse('data.xml').getroot()
except:
print('xml is not well performed')
Upvotes: 1