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 Pat O'Neil <po...@mail.student.oulu.fi> on 2001/11/23 10:57:55 UTC

Deleting objects from the DOM

Hi,
	I have found no documentation that describes deleting a DOM_Node (and
possibly its children) from the heap.  Have I missed reviewing a piece of
sample code, or should I try grabbing pointers and deleting them, or a third
more intelligent alternative that I cannot fathom?

Thanks
Pat O'Neil


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Deleting objects from the DOM

Posted by Erik Rydgren <er...@mandarinen.se>.
Memory allocated to a DOM document is released when the last handle
(DOMDocument object) to the documentimplementation dies. If you need to
alter the document tree then you want to use the DOM_Node::removeChild
method.

  roObsoleteNode = 0; // Only closes the handle to the implementation of the
obsolete node
  roParentNode.removeChild(roObsoleteNode); // Removes the obsolete node
from the DOM tree

The actual memory of the obsolete node is not released until the document
dies.
There is no way for you to remove it earlier.

Regards

Erik Rydgren
Mandarinen systems AB
Sweden

-----Original Message-----
From: Pat O'Neil [mailto:poneil@mail.student.oulu.fi]
Sent: den 23 november 2001 14:17
To: xerces-c-dev@xml.apache.org; Juergen Hermann
Subject: RE: Deleting objects from the DOM


Thanks, but I guess I have a more specific question for your vague answer...

Say I DOMParse and load an existing XML doc, then want to delete an Element,
and any of it's associated child nodes, how would I do it?  Do I simply find
the node of type DOM_Element and assign it =0?  Or must I assign 0 all the
ancestors first?  When you say 'free all memory associated with node' does
this include children?

Thanks again
Pat

-----Original Message-----
From: Juergen Hermann [mailto:jh@web.de]
Sent: 23. marraskuuta 2001 12:24
To: Pat O'Neil; xerces-c-dev@xml.apache.org
Subject: Re: Deleting objects from the DOM


On Fri, 23 Nov 2001 11:57:55 +0200, Pat O'Neil wrote:

>	I have found no documentation that describes deleting a DOM_Node (and
>possibly its children) from the heap.  Have I missed reviewing a piece of
>sample code, or should I try grabbing pointers and deleting them, or a
third
>more intelligent alternative that I cannot fathom?

DOM_Node node;
...
node = 0; // free all memory associated with node





---------------------------------------------------------------------
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


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Deleting objects from the DOM

Posted by Pat O'Neil <po...@mail.student.oulu.fi>.
Thanks, but I guess I have a more specific question for your vague answer...

Say I DOMParse and load an existing XML doc, then want to delete an Element,
and any of it's associated child nodes, how would I do it?  Do I simply find
the node of type DOM_Element and assign it =0?  Or must I assign 0 all the
ancestors first?  When you say 'free all memory associated with node' does
this include children?

Thanks again
Pat

-----Original Message-----
From: Juergen Hermann [mailto:jh@web.de]
Sent: 23. marraskuuta 2001 12:24
To: Pat O'Neil; xerces-c-dev@xml.apache.org
Subject: Re: Deleting objects from the DOM


On Fri, 23 Nov 2001 11:57:55 +0200, Pat O'Neil wrote:

>	I have found no documentation that describes deleting a DOM_Node (and
>possibly its children) from the heap.  Have I missed reviewing a piece of
>sample code, or should I try grabbing pointers and deleting them, or a
third
>more intelligent alternative that I cannot fathom?

DOM_Node node;
...
node = 0; // free all memory associated with node





---------------------------------------------------------------------
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


Re: Deleting objects from the DOM

Posted by Juergen Hermann <jh...@web.de>.
On Fri, 23 Nov 2001 11:57:55 +0200, Pat O'Neil wrote:

>	I have found no documentation that describes deleting a DOM_Node (and
>possibly its children) from the heap.  Have I missed reviewing a piece of
>sample code, or should I try grabbing pointers and deleting them, or a third
>more intelligent alternative that I cannot fathom?

DOM_Node node;
...
node = 0; // free all memory associated with node





---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org