Module: AXML::LibXMLAbstraction

Defined in:
lib/axml.rb

Class Method Summary collapse

Class Method Details

.xml_as_document(xml) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/axml.rb', line 32

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 = LibXML::XML::Document.file(file_name) if File.exists?(file_name)
    end
    xml_document ||= LibXML::XML::Document.string(xml)
  else
    xml_document = xml
  end
  xml_document
end