private Method

XmlSimple.node_to_text(node, default = nil)

Converts a document node into a String. If the node could not be converted into a String for any reason, default will be returned.

node:Document node to be converted.
default:Value to be returned, if node could not be converted.

Source Code

# File active_support/vendor/xml-simple-1.0.11/xmlsimple.rb, line 930
def node_to_text(node, default = nil)
  if node.instance_of?(REXML::Element) 
    node.texts.map { |t| t.value }.join('')
  elsif node.instance_of?(REXML::Attribute)
    node.value.nil? ? default : node.value.strip
  elsif node.instance_of?(REXML::Text)
    node.value.strip
  else
    default
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.