[XML-SIG] Re: getElementsByTagName interpretation
Uche Ogbuji
uogbuji@fourthought.com
Sun, 25 Jun 2000 10:14:19 -0600
> Where this falls down is .getElementByTagName('X'), which returns a
> NodeList containing all 'X' elements in the tree. If this is live,
> then every time you modify the DOM tree by adding, deleting, or moving
> an element, you have to ask "Are there any .getElementByTagName()
> NodeLists out there that would change as a result of this?" If you
> consider a change that moves or deletes many elements, such as
> deleting a chapter from a book, this seems quite expensive and
> time-consuming.
>
> Another nasty situation I can think of is stepping through a NodeList deleting
> the nodes as you step through... in a "live" list, the list you're stepping
> through would be changing as you step... The obvious answer is to step last to
> first, but it's one more argument against "live"ness.
The DOM WG's answer to this is "use NodeIterator or TreeWalker", which is
required to handle this situation gracefully.
--
Uche Ogbuji Principal Consultant
uche.ogbuji@fourthought.com +01 303 583 9900 x 101
Fourthought, Inc. http://Fourthought.com
4735 East Walnut St, Ste. C, Boulder, CO 80301-2537, USA
Software-engineering, knowledge-management, XML, CORBA, Linux, Python