class Nokogiri::XML::Node

def write_to io, *options


node.write_to(io, :indent_text => '-', :indent => 2

To save indented with two dashes:

node.write_to(io, :encoding => 'UTF-8', :indent => 2)

To save with UTF-8 indented twice:

* +:save_with+ a combination of SaveOptions constants.
* +:indent+ the number of +:indent_text+ to use, defaults to 2
* +:indent_text+ the indentation text, defaults to one space
* +:encoding+ for changing the encoding

this method. Valid options are:
Write Node to +io+ with +options+. +options+ modify the output of
##
def write_to io, *options
  options       = options.first.is_a?(Hash) ? options.shift : {}
  encoding      = options[:encoding] || options[0]
  save_options  = options[:save_with] || options[1] || SaveOptions::FORMAT
  indent_text   = options[:indent_text] || ' '
  indent_times  = options[:indent] || 2
  config = SaveOptions.new(save_options)
  yield config if block_given?
  native_write_to(io, encoding, indent_text * indent_times, config.options)
end