text=( text ) public

Sets the first Text child of this object. See text() for a discussion about Text children.

If a Text child already exists, the child is replaced by this content. This means that Text content can be deleted by calling this method with a nil argument. In this case, the next Text child becomes the first Text child. In no case is the order of any siblings disturbed.


If a String, a new Text child is created and added to this Element as the first Text child. If Text, the text is set as the first Child element. If nil, then any existing first Text child is removed.


this Element.

doc = Document.new ‘<a>’ doc.root.text = ‘Sean’ #-> ‘<a>Sean’ doc.root.text = ‘Elliott’ #-> ‘<a>Elliott’ doc.root.add_element ‘c’ #-> ‘<a>Elliott<c/>’ doc.root.text = ‘Russell’ #-> ‘<a>Russell<c/>’ doc.root.text = nil #-> ‘<a><c/>’

Show source
Register or log in to add new notes.