Skip to content

Instantly share code, notes, and snippets.

@slogsdon7
slogsdon7 / ex.py
Last active July 31, 2024 10:27
xml parsing in python
from xml.etree import ElementTree
tree = ElementTree.parse('Users.xml')
root = tree.getroot() # <Element 'users' at 0x105f0e950>
#The root is an array/iterator, so child elements can be accessed with array syntax
row = root[0] # <Element 'row' at 0x105f0e9b0>
row.attrib['DisplayName'] # This is how you access attributes directly
data = []
for row in root: