Method: OpenNebula::XMLElement.build_xml

Defined in:
lib/opennebula/xml_element.rb

.build_xml(xml, root_element) ⇒ Object

Builds a XML document

xml

String the XML document of the object

root_element

String Base xml element

return

XML object for the underlying XML engine



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/opennebula/xml_element.rb', line 55

def self.build_xml(xml, root_element)
    begin
        if NOKOGIRI
            doc = Nokogiri::XML(xml).xpath("/#{root_element}")
        else
            doc = REXML::Document.new(xml).root
        end
    rescue Exception => e
        return OpenNebula::Error.new(e.message)
    end

    return doc
end