Re: Behavior of NodeIterator.toNext()

Hi Tamura,


>
> NodeIterator ni = some_node.getChildNodes();
> Node node = ni.toNext();
>
>In this code, is a variable `node' the first child? Or second
>child?

I would say that this is unknown.  Since the NodeIterator is "live", it
makes sense for the same iterator to be used every time getChildNodes is
called.  It is definately not specified what should happen.  Thus, the
NodeIterator could be anywhere along the list of Nodes.  The only way to be
sure that you are where you think you are is to call one of the other "to"
methods - 'toFirst', 'toLast', 'toNth', or 'toNode'.  If the list is already
there, it shouldn't be an expensive call.  If it isn't, you are now in the
correct place.  It's the only way to guarantee.

David

Received on Tuesday, 7 April 1998 07:16:40 UTC