Path: csiph.com!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'xml,': 0.05; 'snippet': 0.09; 'subject:using': 0.09; 'subject:xml': 0.09; 'advance': 0.10; 'element.': 0.16; 'guys,': 0.16; 'nodes': 0.16; 'subject:search': 0.16; 'string': 0.17; 'received:209.85.214.174': 0.21; 'elements': 0.23; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'node': 0.29; 'parent': 0.29; 'code': 0.31; 'point': 0.31; 'file': 0.32; 'problem': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'received:209.85': 0.35; 'but': 0.36; 'xml': 0.37; 'received:209': 0.37; 'delete': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'remove': 0.61; 'different': 0.63; 'names..': 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=dmv8Bb4/tc8DgoJIOyGmRe/nY8zf7f3BnZfvgLXpKGM=; b=T9cOZXqXJEsZGhlBCPzsomuI40tBtiCvK4F26ty/ZGXcHr64UxmSRZGeyubSPu9FnL WpyAjzKPb+ZwgIUIbSqW2kJVxTNBsaPA/uUHfe2IRcZunb2dqY4gJdclnFd9lNL6BuHH XUHSsiCTU1UMEiukOT+xMer7zGos8eQi9FQWWvuAyMB3MXpFPi4CTc27olgDpUKmnZ/R BpX6YODnlVfzv2eAEuOA1U2H7hqZV/hfxIT2ircNh6zlbePtIIhXgDjQkw18IrKmedZ4 4iVftmNhJ5Aq0N7jkIz0PbOaboKhkgJXUnzU050tY62pBkim1rOD5ZFPJSPRXK0I6EF8 b6hQ== MIME-Version: 1.0 Date: Tue, 16 Oct 2012 14:57:30 +1100 Subject: delete xml elements - using xpath search From: Tharanga Abeyseela 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350359858 news.xs4all.nl 6939 [2001:888:2000:d::a6]:46711 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31359 Hi guys, i need to delete the following pattern and its parent node from my xml file (IF THE SEARCH STRING FOUND) NC if i find the above particular string , i need to delete the XML elements (parent of the element. problem is i have different parent nodes with different names.. like xxx xxx NC xxx NC xxx xxx M as an example, i need to remove section and section from my xml, (because it has the word NC) but need to keep can someone point me to the correct direction, or code snippet Thanks in advance tharanga