re:ElementTree Issue - Search and remove elements

Discussion in 'Python' started by Tharanga Abeyseela, Oct 17, 2012.

  1. 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
     
    Tharanga Abeyseela, Oct 17, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kee Nethery
    Replies:
    12
    Views:
    2,207
    Stefan Behnel
    Jun 27, 2009
  2. Tharanga Abeyseela

    ElementTree Issue - Search and remove elements

    Tharanga Abeyseela, Oct 17, 2012, in forum: Python
    Replies:
    2
    Views:
    180
    Stefan Behnel
    Oct 17, 2012
  3. Stefan Behnel
    Replies:
    0
    Views:
    174
    Stefan Behnel
    Oct 17, 2012
  4. Tharanga Abeyseela
    Replies:
    0
    Views:
    156
    Tharanga Abeyseela
    Oct 17, 2012
  5. Tharanga Abeyseela

    RE:ElementTree Issue - Search and remove elements

    Tharanga Abeyseela, Oct 18, 2012, in forum: Python
    Replies:
    0
    Views:
    177
    Tharanga Abeyseela
    Oct 18, 2012
Loading...

Share This Page