class REXML::Element

def each_element_with_text( text=nil, max=0, name=nil, &block ) # :yields: Element

:yields: Element

...

Output:

a.each_element_with_text('b', 2, '//c') {|e| p e }

and also match the given +xpath+:
that meet the first two criteria,
calls the block with only those child elements
With all arguments given, including +xpath+,

...

Output:

a.each_element_with_text('b', 1) {|e| p e }

calls the block with at most +max+ elements:
With argument +text+ and integer argument +max+,

...
...

Output:

a.each_element_with_text('b') {|e| p e }

calls the block with each element that has exactly that text:
With the single string argument +text+,

...
...
...

Output:

a.each_element_with_text {|e| p e }
a = d.root
d = REXML::Document.new 'bbd'

With no arguments, calls the block with each child element that has text:

Calls the given block with each child element that meets given criteria.

each_element_with_text(text = nil, max = 0, xpath = nil) {|e| ... }
:call-seq:
def each_element_with_text( text=nil, max=0, name=nil, &block ) # :yields: Element
  each_with_something( proc {|child|
    if text.nil?
      child.has_text?
    else
      child.text == text
    end
  }, max, name, &block )
end