uaveiro-leci/1ano/2semestre/labi/tema04/src/xml_reader.py

19 lines
329 B
Python
Raw Normal View History

2023-04-03 20:01:30 +00:00
from lxml import etree
def main(args=None):
xml = etree.parse('../datafiles/conf.xml')
root = xml.getroot()
print(root.tag)
print_childs(root)
def print_childs(root):
for child in root:
print(child.tag, child.attrib, child.text)
print_childs(child)
if __name__ == '__main__':
main()