View Full Version : Total amount of nodes in a document

05-02-2004, 06:11 PM
How can I get the number of total amounts of objects in my document???


05-02-2004, 07:45 PM
By "total amount of nodes," do you mean *all* nodes (attribute notes, comments, etc.), or do you really mean "total amount of elements," or something different?

Also, out of curiosity: what is the purpose of finding the number of nodes in the document?

Happy coding! :)

05-02-2004, 08:21 PM
You can get all element nodes via document.getElementsByTagName("*"). If you want all nodes, a DOM2 NodeIterator is what you'd want to use ideally, though no browser supports it. A recursive call pushing nodes onto a stack would achieve the same thing though.

05-02-2004, 08:26 PM
yea, I need the * , cuz I want to find all elements and assign them A ID if they dont have one laready :D

05-03-2004, 12:45 AM
What is a node?

05-03-2004, 12:50 AM
Already been covered: [http://www.codingforums.com/showthread.php?t=36898]