Method: Nokogiri::XML::Node#inner_text?

Defined in:
lib/ryoba/nokogiri/xml/node.rb

#inner_text?String?

Equivalent to .content.strip, but returns nil if the result is an empty string.

Examples:

xml = Nokogiri::XML("  <body>\n    <h1>\n      Headline 1\n    </h1>\n    <h2> Headline 2 </h2>\n    <h3> </h3>\n  </body>\n")

xml.at("h1").content?  # == "Headline 1"
xml.at("h2").content?  # == "Headline 2"
xml.at("h3").content?  # == nil

Returns:

  • (String, nil)


29
30
31
32
# File 'lib/ryoba/nokogiri/xml/node.rb', line 29

def content?
  result = self.content.strip
  result unless result.empty?
end