The getElementsByTagName method does iterate over the whole tree, comparing tagName with node name and in DOM2 also compares with the namespace URI. You do not gain anything in performance by using getElementsByTagName. But you do not loose any either. Then why invent the wheel again?
If you are on a hunt for a specific childNode (just one matches) then use getElementById instead. Tag the childNode with an ID attribute and use that for lookups. This function is hashed to the extreme and is blazingly fast. Regards Erik Rydgren Mandarinen systems AB Sweden -----Original Message----- From: Aniruddha Shevade [mailto:[EMAIL PROTECTED]] Sent: den 12 april 2002 00:17 To: [EMAIL PROTECTED] Subject: Performance comparison - getElementsByTagName and GetChildNodes() Hello After having parsed the xml, I want to find a particular element. I have two approaches 1) The Most obvious is to call getElementsByTagName. 2) USe getChildNodes and iterate over the list, and compare the node names. My question is does getElementByTagName internally do the same thing , as iterating the entire DOM tree and comparing node names ? Or does it use any sort of indexing ? In other words would getElementsByTagName be a better choice ? Any help is appreciated. thanks -Aniruddha --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
