Class: Nokogiri::XML::Document

Inherits:
Node
  • Object
show all
Defined in:
lib/nokogiri/ext/traverse_count/document.rb

Instance Method Summary collapse

Methods inherited from Node

#==, #traverse_text

Instance Method Details

#traverse_countInteger

Calculates the sum of all sub-children of the document.

Returns:

  • (Integer)

    The total number of children and sub-children of the document. Returns 0 if the document has no root element.



18
19
20
21
22
23
24
# File 'lib/nokogiri/ext/traverse_count/document.rb', line 18

def traverse_count
  if root
    1 + root.traverse_count
  else
    0
  end
end