Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31545 > unrolled thread
| Started by | Tharanga Abeyseela <tharanga.abeyseela@gmail.com> |
|---|---|
| First post | 2012-10-18 09:31 +1100 |
| Last post | 2012-10-18 09:31 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
re:ElementTree Issue - Search and remove elements Tharanga Abeyseela <tharanga.abeyseela@gmail.com> - 2012-10-18 09:31 +1100
| From | Tharanga Abeyseela <tharanga.abeyseela@gmail.com> |
|---|---|
| Date | 2012-10-18 09:31 +1100 |
| Subject | re:ElementTree Issue - Search and remove elements |
| Message-ID | <mailman.2368.1350513108.27098.python-list@python.org> |
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
Back to top | Article view | comp.lang.python
csiph-web