Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31545 > unrolled thread

re:ElementTree Issue - Search and remove elements

Started byTharanga Abeyseela <tharanga.abeyseela@gmail.com>
First post2012-10-18 09:31 +1100
Last post2012-10-18 09:31 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  re:ElementTree Issue - Search and remove elements Tharanga Abeyseela <tharanga.abeyseela@gmail.com> - 2012-10-18 09:31 +1100

#31545 — re:ElementTree Issue - Search and remove elements

FromTharanga Abeyseela <tharanga.abeyseela@gmail.com>
Date2012-10-18 09:31 +1100
Subjectre: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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web