Skip to main content

XML_Element.child_count

child_count

Group: Metadata

Documentation

Gets the number children of an XML element. child_count only counts child elements and child text nodes that are not 100% whitespace. Other node types, such as comments, are not included in the count.

Examples

Get the number of children of an element.

      XML_Document.parse '<foo> <bar>hello</bar> <bar>hello2</bar>< </foo>' . root_element . child_count
# => 2