class REXML::Element

def add_text( text )


a.to_a # => ["foo", , "bar", "baz", "baz"]
a.add_text(REXML::Text.new('baz'))
a.to_a # => ["foo", , "bar", "baz"]
a.add_text(REXML::Text.new('baz'))
a = d.root
d = REXML::Document.new('foobar')

returns +self+:
appends the node as the last text node in the element;
When text node argument +text_node+ is given,

a.to_a # => ["foo", , "barbazbaz"]
a.add_text('baz')
a.to_a # => ["foo", , "barbaz"]
a.add_text('baz')
a = d.root
d = REXML::Document.new('foobar')

appends the string to the _last_ text node:
If the element has child text nodes,

a.to_a # => [, "foo"]
a.add_text('foo')
a = d.root
d = REXML::Document.new('')

then adds that node to the element:
honoring the current settings for whitespace and raw,
creates a \REXML::Text object using the string,
If the element has no child text node,

When string argument +string+ is given, returns +nil+.

Adds text to the element.

add_text(text_node) -> self
add_text(string) -> nil
:call-seq:
def add_text( text )
  if text.kind_of? String
    if @children[-1].kind_of? Text
      @children[-1] << text
      return
    end
    text = Text.new( text, whitespace(), nil, raw() )
  end
  self << text unless text.nil?
  return self
end