Answers for "extracting data from xml"

0

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)
Posted by: Guest on March-04-2021

Code answers related to "extracting data from xml"

Browse Popular Code Answers by Language