Class: ROXML::XML::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/roxml/xml.rb

Class Method Summary collapse

Class Method Details

.from(data) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/roxml/xml.rb', line 19

def self.from(data)
  case data
  when XML::Node
    data
  when XML::Document
    data.root
  when File, IO
    XML.parse_io(data).root
  else
    if (defined?(URI) && data.is_a?(URI::Generic)) ||
       (defined?(Pathname) && data.is_a?(Pathname))
      XML.parse_file(data.to_s).root
    else
      XML.parse_string(data).root
    end
  end
end