[XML-SIG] Optimizing getElementsByTagName()

Uche Ogbuji uche.ogbuji@fourthought.com
Fri, 27 Apr 2001 21:20:01 -0600


> In my processing I'm using getElementsByTagName() a lot. I notice that
> in the current implementation is recalculates the subelement list every
> time you call it.

This is just a naive way to satisfy at least a portion of the (silly, IMHO) 
liveness requirements of the DOM.

> An obvious optimization would be to cache lists by tagName once
> calculated.
> 
> Is this an appropriate optimization? It would have some memory cost.

I pretty much don't know how to *spell* getElementsbyTagName anymore.

My optimization for this is to use XPath.

I know it might not be suitable for your needs, but just a thought...


-- 
Uche Ogbuji                               Principal Consultant
uche.ogbuji@fourthought.com               +1 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