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


Groups > comp.lang.python > #31545

re:ElementTree Issue - Search and remove elements

Date 2012-10-18 09:31 +1100
Subject re:ElementTree Issue - Search and remove elements
From Tharanga Abeyseela <tharanga.abeyseela@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2368.1350513108.27098.python-list@python.org> (permalink)

Show all headers | View raw


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 comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web