Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31564
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <tharanga.abeyseela@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'root': 0.04; 'python': 0.09; 'elt': 0.16; 'feed.': 0.16; 'guys,': 0.16; 'subject:remove': 0.16; 'element': 0.17; 'subject:Issue': 0.17; 'thanks,': 0.18; '(not': 0.20; 'file.': 0.20; 'trying': 0.21; 'import': 0.21; 'received:209.85.214.174': 0.21; 'matching': 0.23; 'skip:# 10': 0.27; 'tree': 0.27; 'message-id:@mail.gmail.com': 0.27; 'node': 0.29; 'parent': 0.29; "i'm": 0.29; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'but': 0.36; 'xml': 0.37; 'why': 0.37; 'received:209': 0.37; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'url:schemas': 0.39; 'header:Received:5': 0.40; 'remove': 0.61; 'subject::': 0.83; 'subject:Search': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=tpXc0IiqHlfORvbQSByijqSQbgfWaC3Wv7LJvPSaUx4=; b=KvRt2A8UoQsXW9OORoc6odGZ4cFoLhvAAOmIBcHhkXkNjgWxdY6nYS0tWNBMlBR9Pd yCbOe/TYS2TqDr155iixRmmbIHDHmOmSWM/3SpJmR2GEoolGiEXDe/ziCMtlc8FGC5Eh CALV7qP8pWaOo0dX+TX2NKTR2JIBmLfOCQ6bZhsViDLFFtI9UZIl7sdwjxyuDJG9uG6l 93dtjRShtcxYWKzdZSyl41IBSa8VcpHuf52SZNk9n0P0RqfslMd4hJmGcuSSBT8X8Z1d RFvarjy8D05pIVrFvlDGpdkl20aly35Ma9JM1NuM22Ijo2QqsZHIlDgMajWjIuJCmDa8 fFlw== |
| MIME-Version | 1.0 |
| Date | Thu, 18 Oct 2012 12:05:42 +1100 |
| Subject | RE:ElementTree Issue - Search and remove elements |
| From | Tharanga Abeyseela <tharanga.abeyseela@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2380.1350522346.27098.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1350522346 news.xs4all.nl 6922 [2001:888:2000:d::a6]:46290 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:31564 |
Show key headers only | View raw
Hi Guys,
Managed to find the element from my xml feed. but i'm having an issue
when trying to remove the parent node and write the xml file.
#!/usr/bin/env python
import elementtree.ElementTree as ET
tree = ET.parse('test.xml')
root = tree.getroot()
walkAll = tree.getiterator()
for elt in walkAll:
for x in
elt.findall('.//{http://schemas.xxxx.com/xxx/2xx/0x/xx/ixxxx}Rating'):
if x.text=="NC":
tree.remove(elt)
else:
tree.write('out.xml')
i was trying to remove the element (not the element tag).
why i cant remove the elt element from root if i found the NC matching pattern.
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-18 12:05 +1100
csiph-web