>1) The Most obvious is to call getElementsByTagName.
>2) USe getChildNodes and iterate over the list, and compare the node
names.

getElementsByTagName scans all the descendents, not just the immediate
children. To achieve the equivalent of (1), you'd have to wrap some
recursion around (2).

>  My question is does getElementByTagName internally do the same thing ,
> as iterating the entire DOM tree and comparing node names ?

As of the last time I looked, the answer was "yes" -- using a nonrecursive
tree-walker. If you want to be sure, check the source code. Note that since
this is an implementation detail, it may change without notice.

Note that there are other ways to approach this: Walk the tree yourself, or
use a DOM Level 2 NodeIterator or TreeWalker set to only accept elements
that have the name you're looking for, or prescan the document and build
your own name-to-set-of-elements map...



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to