You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Gareth Reakes <ga...@decisionsoft.com> on 2001/01/13 12:38:38 UTC

Re: What about the children? (was How to remove a node and all its c hildren?)

Glad to  help.
As you suspect, removing a node also removes its children as they are
content. 

Gareth

On Sat, 13 Jan 2001, Foong, Tzeweng wrote:

> Thanks Miroslaw, Gareth and  Joseph for your replys. I now understand !!  
> 
> Better still...  My code works !! ....   
> 
> However Thinking about it a bit more. ...  What if I just removed the
> Top-level Node
> In my example file (below) It would be the <COMPONENT> Node. What would 
> happen to all the related attached nodes ?  Do I need to remove each one
> individually
> or will they all disapear by magic as I suspect they will?
> 
> <COMPONENTS>
>  <COMPONENT NAME="Make Partitions" Version="3.0">
>   <TASK TIME="20010111.183411" TYPE="Retreive"/>
>   <TASK TIME="20010111.183413" TYPE="FailedRetrieve"/>
>  </COMPONENT>
>  <COMPONENT NAME="Format Partitions" Version="3.0">
>   <TASK TIME="20010111.184203" TYPE="Retreive"/>
>   <TASK TIME="20010111.184205" TYPE="FailedRetrieve"/>
>  </COMPONENT>
> </COMPONENTS>
> 
> Again, Thanks for the replies.
> 
> Tze Weng Foong
> 
> 
> > -----Original Message-----
> > From:	Miroslaw Dobrzanski-Neumann [SMTP:mne@mosaic-ag.com]
> > Sent:	Thursday, 11 January 2001 20:15
> > To:	xerces-c-dev@xml.apache.org
> > Subject:	Re: How to remove a node and all its children?
> > 
> > On Thu, Jan 11, 2001 at 07:58:40PM +1100, Foong, Tzeweng wrote:
> > > Hello List,
> > > 
> > > Is there a simple way to remove a node and all its children. I have
> > looked 
> > > through the docs and found the RemoveChild method but I am crashing 
> > > the program. 
> > > 
> > > The code below is what I am using to try to do it. (It fails miserably).
> > > "aICNode" is a 
> > > DOM_Node and I want to remove it and all its child nodes from the
> > > DOM_Document.
> > > 
> > > DOM_NodeList ICNodeTasks = aICNode.getChildNodes();
> > > int NumTasks = ICNodeTasks.getLength();
> > > for (int i = 1 ; i <= NumTasks ; i ++)
> > >             {
> > >                 aICNode.removeChild( ICNodeTasks.item(i) );
> > >             }
> > 
> > DOM_NodeList shares the same children as the underlying Node. If you
> > remove a
> > child the list will be shortened.
> > 
> > the corret code:
> > for (int i = 1 ; i <= NumTasks ; i ++) {
> > 	aICNode.removeChild(ICNodeTasks.item(0);
> > }
> > 
> > -- 
> > I'd be pleased with any feedback. In the absence of such I'll make my own
> > choices. Actually, though, I'd love and answer any question.
> > ===================================
> > Miroslaw Dobrzanski-Neumann
> > 
> > MOSAIC SOFTWARE AG
> > Abteilung Basisentwicklung und Forschung
> > Tel +49-2225-882-291
> > Fax +49-2225-882-201
> > E-mail: mne@mosaic-ag.com
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> 
>