Sometimes, we will get an XML response from the server, and we have to parse the XML to extract the data. We can use the xml.etree.ElementTree module to parse the XML files.
Parsing XML data
Getting ready
We have to install the required module, xml:
pip install xml
How to do it...
Here is how we can parse XML data with XML module:
- First import the required modules. As this script is in Python 3, make sure that you import the correct modules:
from urllib.request import urlopen from xml.etree.ElementTree import parse
- Now get the XML file with the urlopen method in...