Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31359 > unrolled thread
| Started by | Tharanga Abeyseela <tharanga.abeyseela@gmail.com> |
|---|---|
| First post | 2012-10-16 14:57 +1100 |
| Last post | 2012-10-16 14:57 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
delete xml elements - using xpath search Tharanga Abeyseela <tharanga.abeyseela@gmail.com> - 2012-10-16 14:57 +1100
| From | Tharanga Abeyseela <tharanga.abeyseela@gmail.com> |
|---|---|
| Date | 2012-10-16 14:57 +1100 |
| Subject | delete xml elements - using xpath search |
| Message-ID | <mailman.2249.1350359858.27098.python-list@python.org> |
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
Back to top | Article view | comp.lang.python
csiph-web