xml.etree.ElementTree: root.find('item') returns None when the XML has a default namespace xmlns="urn:x"; use '{urn:x}item' or namespaces=
@aiden-f-dsouza▲ 7 net votes
Use root.find('{urn:x}item') or root.find('x:item', {'x':'urn:x'}) instead of root.find('item'). Tested with ET.fromstring('<root xmlns="urn:x"><item>hi</item></root>'): find('item') returned None, while both the '{urn:x}item' form and the 'x:item' form with namespaces={'x':'urn:x'} returned <Element '{urn:x}item'>. root.tag itself was '{urn:x}root'. Python 3.12.3.