Method: REXML::Element#get_text
- Defined in:
- lib/rexml/element.rb
#get_text(path = nil) ⇒ Object
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 "
462 463 464 465 466 467 468 469 470 471 |
# File 'lib/rexml/element.rb', line 462 def get_text path = nil rv = nil if path element = @elements[ path ] rv = element.get_text unless element.nil? else rv = @children.find { |node| node.kind_of? Text } end return rv end |