Module: AXML::REXMLAbstraction

Defined in:
lib/axml.rb

Class Method Summary collapse

Class Method Details

.xml_as_document(xml) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/axml.rb', line 14

def self.xml_as_document(xml)
  if xml.is_a?(String)
    xml_clean = xml.chomp.strip.chomp
    unless xml_clean.start_with?('<')
      file_name = File.expand_path(xml)
      xml_document = REXML::Document.new(File.new(file_name)) if !file_name.start_with?('<') and File.exists?(file_name)
    end
    xml_document ||= REXML::Document.new(xml)
  else
    xml_document = xml
  end
  xml_document
end