extracting data from xml code example
Example: extracting data from xml
Just loop through the list and print the text of each element.
import urllib.request, urllib.parse, urllib.error
import xml.etree.ElementTree as ET
url = 'http://py4e-data.dr-chuck.net/comments_42.xml'
uh = urllib.request.urlopen(url)
data = uh.read()
tree = ET.fromstring(data)
lst = tree.findall('comments/comment/count')
counts = tree.findall('.//count')
for each in counts:
print(each.text)