loading
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import xml.etree.ElementTree as ET
tree = ET.parse('persons.xml')
root = tree.getroot()

print(ET.tostring(root, encoding='utf8').decode('utf8'))

print('\nNumber of Elements:')
print(len(root))
print('\nNumber of Sub-Elements:')
print(len(root[0]))

print('\nElem/Sub-Elem Data:')
for elem in root:
	for subelem in elem:
		print(subelem.tag + ":" + subelem.text)