class Magnesium::XML

Public Class Methods

closeXML(file) click to toggle source
# File lib/magnesium/support/xml.rb, line 29
  def self.closeXML(file)
    begin
      file.close
    rescue
      error
#ensure
    end
  end
modify_attribute(filepath,path,attribute,value) click to toggle source
# File lib/magnesium/support/xml.rb, line 38
  def self.modify_attribute(filepath,path,attribute,value)
    begin
      file = File.read(filepath)
      doc = Document.new file

      doc.elements.each(path) do |e|
        e.add_attribute(attribute,value)
      end
      File.delete(filepath)
      f = File.new(filepath,'w+')
      puts 'M: Let\'s review the config file.'
      puts '............................................................'
      f.puts doc.write
    rescue
      error
#ensure
    end
  end
new_document(file) click to toggle source
# File lib/magnesium/support/xml.rb, line 19
  def self.new_document(file)
    begin
      doc = Document.new file
      return doc
    rescue
      error
#ensure
    end
  end
openXML(path) click to toggle source
# File lib/magnesium/support/xml.rb, line 9
  def self.openXML(path)
    begin
      file = File.read(path)
      return file
    rescue
      error
#ensure
    end
  end