Class: ROXML::XML::Document

Inherits:
Object
  • Object
show all
Includes:
NamespacedSearch
Defined in:
lib/roxml/xml/parsers/rexml.rb,
lib/roxml/xml/parsers/libxml.rb

Instance Method Summary collapse

Methods included from NamespacedSearch

#search

Instance Method Details

#root=(node) ⇒ Object

Raises:

  • (ArgumentError)


71
72
73
74
# File 'lib/roxml/xml/parsers/rexml.rb', line 71

def root=(node)
  raise ArgumentError, "Root is already defined" if root
  add(node)
end

#save(destination, opts = {:formatter => REXML::Formatters::Default.new}) ⇒ Object



76
77
78
79
80
81
# File 'lib/roxml/xml/parsers/rexml.rb', line 76

def save(destination, opts = {:formatter => REXML::Formatters::Default.new})
  self << REXML::XMLDecl.new unless xml_decl != REXML::XMLDecl.default # always output xml declaration
  File.open(destination, "w") do |f|
    opts[:formatter].write(self, f)
  end
end