ElementTree Issue - Search and remove elements
Tharanga Abeyseela
tharanga.abeyseela at gmail.com
Wed Oct 17 18:31:39 EDT 2012
Hi,
Thanks Alian, i was trying to use the following , but i got a path
separator error. I'm using python 2.4.3. is there any otherway i can
use this on 2.4.3
#!/usr/bin/env python
import elementtree.ElementTree as ET
tree = ET.parse('test.xml')
root = tree.getroot()
for child in root.findall(".//*[ParentalControl]"):
x = child.find("ParentalControl/Rating").text
if x == "NC":
root.remove(child)
Thanks,
Tharanga
More information about the Python-list
mailing list