get_text(path = nil)public
Returns the first child Text node, if any, or nil otherwise. This method returns the actual Text node, rather than the String content.
doc = Document.new "<p>some text <b>this is bold!</b> more text</p>" # The element 'p' has two text elements, "some text " and " more text". doc.root.get_text.value #-> "some text "
1Note
Get all inner texts
Extend REXML::Element so that it can get the first text and following inner texts (child texts included) of the current element as array and as string:
class REXML::Element
def inner_texts
REXML::XPath.match(self,'.//text()') end
def inner_text
REXML::XPath.match(self,'.//text()').join end
end