Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31479
| Date | 2012-10-17 18:19 +1100 |
|---|---|
| Subject | re: ElementTree Issue - Search and remove elements |
| From | Tharanga Abeyseela <tharanga.abeyseela@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2329.1350458350.27098.python-list@python.org> (permalink) |
Thanks Stefan,
i managed to iterate through the file like this.
import elementtree.ElementTree as ET
tree = ET.parse('test.xml')
root = tree.getroot()
walkAll = tree.getiterator()
for elt in walkAll:
#print elt.tag
x = elt.tag
if x == "{http://xxxx.xx.com/xxxx/2011/06/13/ingestion}Rating":
if elt.text == "NC":
print elt.text #### here i can see all my NC values
else:
print "not found" ####all other stuff are coming here..
but how should i remove the parent from the NC checking part?
thanks,
Tharanga
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
re: ElementTree Issue - Search and remove elements Tharanga Abeyseela <tharanga.abeyseela@gmail.com> - 2012-10-17 18:19 +1100
csiph-web