Flowdock
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 this is bold! more text</p>” # The element ‘p’ has two text elements, “some text ” and “ more text”. doc.root.get_text.value #-> “some text

Show source
Register or log in to add new notes.
October 19, 2009
1 thank

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