class Nokogiri::XML::Node
def serialize(*args, &block)
end
config.format.as_xml
node.serialize(encoding: 'UTF-8') do |config|
or
node.serialize(encoding: 'UTF-8', save_with: FORMAT | AS_XML)
These two statements are equivalent:
See also Nokogiri::XML::Node::SaveOptions and Node@Serialization+and+Generating+Output.
Serialize Node using +options+. Save options can also be set using a block.
##
def serialize(*args, &block) # TODO: deprecate non-hash options, see 46c68ed 2009-06-20 for context options = if args.first.is_a?(Hash) args.shift else { encoding: args[0], save_with: args[1], } end options[:encoding] ||= document.encoding encoding = Encoding.find(options[:encoding] || "UTF-8") io = StringIO.new(String.new(encoding: encoding)) write_to(io, options, &block) io.string end