Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Remove xml node and containing parent node that has a specific string
import xml.etree.ElementTree as ET
tree = ET.parse('testdata.xml')
root = tree.getroot()
for parentNode in root.findall('ParentXMLTag'):
childNode = parentNode.find('ChildXMLTag').text
search_string = "Lorem Ipsum"
if childNode == search_string:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.