delete xml elements - using xpath search

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

  1. Hi guys,


    i need to delete the following pattern and its parent node from my xml
    file (IF THE SEARCH STRING FOUND)

    <Rating>NC</Rating>

    if i find the above particular string , i need to delete the XML
    elements (parent of the <Rating> element. problem is i have different
    parent nodes with different names..

    like

    <movies>
    <name> xxx</name>
    <title>xxx </title>
    <Rating>NC</Rating>
    </movies>

    <tvshow>
    <name> </name>
    <title>xxx </title>
    <Rating>NC</Rating>
    </tvshow>

    <tvepisode>
    <name>xxx </name>
    <title>xxx </title>
    <Rating>M</Rating>
    </tvepisode>


    as an example, i need to remove <movies> section and <tvshow> section
    from my xml, (because it has the word NC) but need to keep <tvepisode>

    can someone point me to the correct direction, or code snippet

    Thanks in advance
    tharanga
     
    Tharanga Abeyseela, Oct 16, 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. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    2,031
    jan V
    Jul 29, 2005
  2. ETL
    Replies:
    9
    Views:
    852
  3. Ultrus
    Replies:
    4
    Views:
    2,857
    Stefan Behnel
    Aug 30, 2007
  4. Claudio Calboni
    Replies:
    4
    Views:
    267
  5. Stefan Behnel
    Replies:
    0
    Views:
    171
    Stefan Behnel
    Oct 16, 2012
Loading...

Share This Page