def serialize *args, &block
if args.first && !args.first.is_a?(Hash)
$stderr.puts("\#{self.class}#serialize(encoding, save_opts) is deprecated and will be removed in\nNokogiri version 1.4.0 *or* after June 1 2009.\nYou called serialize from here:\n\n\#{caller.first}\n\nPlease change to \#{self.class}#serialize(:encoding => enc, :save_with => opts)\n")
end
options = args.first.is_a?(Hash) ? args.shift : {
:encoding => args[0],
:save_with => args[1] || SaveOptions::FORMAT
}
io = StringIO.new
write_to io, options, &block
io.rewind
io.read
end