KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an XML document in which I want to search for some elements and if they match some criteria I would like to delete them However, I cannot seem to be able to access the parent of the element so that I can delete it file = open('test.xml', "r") elem = ElementTree.parse(file) namespace = "{http://somens}" props = elem.findall('.//{0}prop'.format(namespace)) for prop in props: type = prop.attrib.get('type', None) if type == 'json': value = json.loads(prop.attrib['value']) if value['name'] == 'Page1.Button1': #here I need to access the parent of prop # in order to delete the prop Is there a way I can do this? Thanks
Tags (comma-separated)
Save Edits
Cancel