|
Thanks for the info. Wow, that's a
pain.
so in order to remove a set of child elements from
one node to another, i need to use my own container, then.
Thanks again.
----- Original Message -----
Sent: Sunday, April 10, 2005 10:41
AM
Subject: Re: Odd Behavior for
getChildNodes() ?
"Dave Brosius" <[EMAIL PROTECTED]> wrote on 04/10/2005
12:21:07 AM:
> I'm using the DOM3 version of xerces, and am doing
the following: >
> NodeList els= type.getChildNodes(); >
for (int i = 0; i < els.getLength(); i++) >
type.removeChild(els.item(i)); > > I still want to
hold onto these child nodes, the problem is that > xerces implements
NodeList using ElementNSImpl in this case, > and further, the Element that is returned via getChildNodes,
is the > node itself, so in the above, > > els ==
type > > because of this, 'els' will be empty at the end of this
method. > > This would seem to be a mistake to me, no?
>
The
following from the DOM Level 3 Core spec may help explain this:
"NodeList and NamedNodeMap objects in the DOM are
live; that is, changes to the underlying document structure are reflected in
all relevant NodeList and NamedNodeMap objects. For example, if a DOM user
gets a NodeList object containing the children of an Element, then
subsequently adds more children to that element (or removes children, or
modifies them), those changes are automatically reflected in the NodeList,
without further action on the user's
part."
|