We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fdffd7e commit bd03751Copy full SHA for bd03751
xmltest.py
@@ -0,0 +1,21 @@
1
+import urllib.request as ur
2
+import xml.etree.ElementTree as et
3
+
4
+url = input('Enter location: ')
5
+# 'http://python-data.dr-chuck.net/comments_42.xml'
6
7
+total_number = 0
8
+sum = 0
9
10
+print('Retrieving', url)
11
+xml = ur.urlopen(url).read()
12
+print('Retrieved', len(xml), 'characters')
13
14
+tree = et.fromstring(xml)
15
+counts = tree.findall('.//count')
16
+for count in counts:
17
+ sum += int(count.text)
18
+ total_number += 1
19
20
+print('Count:', total_number)
21
+print('Sum:', sum)
0 commit comments