> The Node interface, as specified by the DOM, doesn't have a > 'deleteChildNode' operation. It instead has a 'removeChild' operation. The > DOM specification intentionally left memory management details to > implementors. > > public Node removeChild(Node oldChild) > throws DOMException; > > The removeChild operation removes a child from a parent's child list, and > returns it to the caller. > With an implementation that supports garbage collection (like Java or > JavaScript), if you don't retain a reference to the removed node, it will > eventually be deleted. With an implementation that doesn't support garbage > collection, it's up to the implementation to specify how the node is > deleted. >
And, to answer the question specifically for the Xerces-C DOM, it is very similar to Java. Nodes are reference counted. If you call DOM_Node::removeChild(), the node removed from the document will remain available so long as the application has a DOM_Node variable that refers to it. When all references to the removed node(s) are dropped, the nodes themselves will be automatically deleted by the implementation. The same holds for the document itself; when all references to it (in the form of DOM_Node or DOM_Document or DOM_whatever variables) in the application code go out of scope, the document itself will be deleted.