Skip to content

Instantly share code, notes, and snippets.

@afaqk9394
Last active November 2, 2019 21:02
Show Gist options
  • Select an option

  • Save afaqk9394/5d241e08782ad15950431540bc3c7d10 to your computer and use it in GitHub Desktop.

Select an option

Save afaqk9394/5d241e08782ad15950431540bc3c7d10 to your computer and use it in GitHub Desktop.
import xml.etree.ElementTree as ET
tree = ET.parse('persons.xml')
root = tree.getroot()
# total number of nodes from root
print('\nNumber of Nodes:')
print(len(root[0]))
# all nodes data
print('\nNode Data:')
for elem in root:
for subelem in elem:
print(subelem.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment