From kevolson@visi.com Fri Feb 4 21:15:06 2000 Return-Path: Mailing-List: contact general-help@xml.apache.org; run by ezmlm Delivered-To: mailing list general@xml.apache.org Received: (qmail 63023 invoked from network); 4 Feb 2000 21:15:06 -0000 Received: from kauket.visi.com (HELO mail-out.visi.com) (209.98.98.22) by locus.apache.org with SMTP; 4 Feb 2000 21:15:06 -0000 Received: from isis.visi.com (isis.visi.com [209.98.98.8]) by mail-out.visi.com (Postfix) with ESMTP id 7DC2A39EF for ; Fri, 4 Feb 2000 15:15:05 -0600 (CST) Received: from localhost (kevolson@localhost) by isis.visi.com (8.8.8/8.8.8) with ESMTP id PAA26273 for ; Fri, 4 Feb 2000 15:15:05 -0600 (CST) X-Authentication-Warning: isis.visi.com: kevolson owned process doing -bs Date: Fri, 4 Feb 2000 15:15:05 -0600 (CST) From: Kevin Olson To: "'general@xml.apache.org'" Subject: RE: Question about removeChild In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Many thanks Brian, that clears it up. Kevin On Fri, 4 Feb 2000, Brian Dupras wrote: > > Am I missing something in the DOM spec or the Xerces API? > > Yes = NodeLists are live. That means if you created a NodeList of children > of a node, if you delete a child, it gets removed from the NodeList, too. > > Original NodeList > child 0 : > child 1 : > child 2 : > > Same NodeList after .removeChild(): > > child 0 : > child 1 : > > > > One way to work around this is to iteraet backward over the nodelist. If > you remove the last Node, the other nodes don't change place like if you > delete the first. > > Brian > > > > -----Original Message----- > > From: Kevin Olson [mailto:kevolson@visi.com] > > Sent: Friday, February 04, 2000 1:55 PM > > To: general@xml.apache.org > > Subject: Question about removeChild > > > > > > Hello all, > > > > Using Xerces 1.0.1 and given the following doc... > > > > > > > > > > > > > > > > > > I am iterating through a NodeList trying to delete the > > element and > > the element. I reach the element and do the following > > (where 'n' is the current node in the NodeList). > > > > Node parent = n.getParentNode(); > > parent.removeChild(n); > > > > And the node gets blasted like I would expect. I > > would also expect > > to be able to delete the element in the next iteration of the > > NodeList. What happens, however, is that the next node in > > the list is the > > node. > > > > It works if I try to delete the and node. > > Just not two > > consecutive nodes with the same parent. I can show more of > > the code if > > that would help. > > > > Am I missing something in the DOM spec or the Xerces API? > > > > Thanks, > > Kevin > > > > > > >