Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Total amount of nodes in a document

    How can I get the number of total amounts of objects in my document???


    thanks

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #3
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yea, I need the * , cuz I want to find all elements and assign them A ID if they dont have one laready

  • #5
    Regular Coder
    Join Date
    Jan 2004
    Location
    Maryland
    Posts
    468
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What is a node?

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Location
    Kansas City, Kansas
    Posts
    1,518
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Already been covered: [What's a node?]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •