add_text( text ) public

A helper method to add a Text child. Actual <a href="/ruby/REXML/Text">Text</a> instances can be added with regular Parent methods, such as add() and <<()

text:if a String, a new Text instance is created and added to the parent. If <a href="/ruby/REXML/Text">Text,</a> the object is added directly.
Returns:this Element
 e = Element.new('a')          #-> <e/>
 e.add_text 'foo'              #-> <e>foo</e>
 e.add_text Text.new(' bar')    #-> <e>foo bar</e>

Note that at the end of this example, the branch has 3 nodes; the ‘e’ element and 2 Text node children.

Show source
Register or log in to add new notes.