W3C home > Mailing lists > Public > www-dom@w3.org > April to June 1998

Re: Behavior of NodeIterator.toNext()

From: David Peterson <david.peterson@iname.com>
Date: Tue, 7 Apr 1998 21:15:55 +1000
Message-ID: <001f01bd6216$926d96a0$0200a8c0@down>
To: <www-dom@w3.org>
Hi Tamura,

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

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.

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

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:03 UTC