import urllib.request, urllib.parse, urllib.error
import xml.etree.ElementTree as ET
_url = input("Enter XML URL : ")
if not _url :
_url = "http://py4e-data.dr-chuck.net/comments_207835.xml"
_response = urllib.request.urlopen(_url)
#print(_response.read().decode())
_xml = ET.fromstring(_response.read().decode()) # _response.read() The bytes type is also allowed.
print(_xml.find("note").text)
_comments = _xml.findall("comments/comment")
print("Comment count :", len(_comments))
print()
print("{:20} {:10}".format("name", "count"))
print("-" * 20, "-" * 10)
for _comment in _comments :
#print("name :", _comment.find("name").text)
#print("count :", _comment.find("count").text)
#print()
print("{:20} {:10}".format(_comment.find("name").text, _comment.find("count").text))
>>> exec(open("xml02.py").read())
Enter XML URL :
This file contains the actual data for your assignment - good luck!
Comment count : 50
name count
-------------------- ----------
Vladimir 98
Etiene 98
Kharli 96
Millicent 95
Nathanael 94
Kashish 91
Amylee 88
Lucca 88
Ozzy 88
Jaina 87
Darrie 87
Demira 85
Shannah 80
Kasra 78
Tea 78
Ubayd 76
Nivyn 74
Manus 71
Ally 69
Ehsan 68
Avanya 67
Nicol 67
Parker 64
Keana 60
Sianade 58
Hamid 57
Umer 57
Teighen 54
Dedeniseoluwa 52
Lochlan 49
Woyenbrakemi 49
Ashleigh 49
Robbi 46
Naima 44
Nour 43
Kyna 39
Chelsie 38
Billiejo 34
Phani 29
Shanade 28
Alyas 27
Jena 26
Limbiadhe 26
Cassy 23
Meyzhward 22
Silas 21
Debbie 16
Nicky 8
Letizia 4
Coel 2
xml 파싱 2
|
2019.09.03 15:15:19
|
2019.09.03 15:15:19
|
414
|
Aiden
Total of Attached file
0.00 Bytes of 0 files
2019.09.25
2019.09.24
2019.09.16
2019.09.14
2019.09.03
2019.09.03
2019.08.30
2019.08.30
2019.08.30