I am having an issue trying to extract the email from a xml file using Python3.
My code is:
import xml.etree.ElementTree as ET
import ssl
# Ignore SSL certificate errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
data = '''<row>
<row _id="row-jyi7-56ru_b7km" _uuid="00000000-0000-0000-B614-7FFDD7C1595B" _position="0" _address="https://www.dati.lombardia.it/resource/zzzz-zzzz/row-jyi7-56ru_b7km">
<codice_regionale>MI1604</codice_regionale>
<denom_farmacia>Farmacia Varesina</denom_farmacia>
<indirizzo>VIA VARESINA, 121</indirizzo>
<localita>Milano</localita>
<telefono>3480813398</telefono>
<email>[email protected]</email>
<caratterizzazione>urbana</caratterizzazione>
<esenzioni>true</esenzioni>
<location latitude="45.500881" longitude="9.141339"/>
</row>'''
tree = ET.fromstring(data) #standard ET
results = tree.findall('email') #find the count section in xml
print(results.text)
The error I get is
Traceback (most recent call last):
File "farmacie.py", line 25, in <module>
tree = ET.fromstring(data) #standard ET
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/xml/etree/ElementTree.py", line 1321, in XML
return parser.close()
xml.etree.ElementTree.ParseError: no element found: line 12, column 6
How can I solve this?