Method: Nokogiri::XML::NodeSet#text

Defined in:
lib/nokogiri/xml/node_set.rb

#textObject

Get the inner text of all contained Node objects

Note: This joins the text of all Node objects in the NodeSet:

doc = Nokogiri::XML('<xml><a><d>foo</d><d>bar</d></a></xml>')
doc.css('d').text # => "foobar"

Instead, if you want to return the text of all nodes in the NodeSet:

doc.css('d').map(&:text) # => ["foo", "bar"]

See Nokogiri::XML::Node#content for more information.



258
259
260
# File 'lib/nokogiri/xml/node_set.rb', line 258

def inner_text
  collect(&:inner_text).join("")
end