1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-25 02:50:08 +03:00

Merge branch 'bug-381'

This commit is contained in:
Ruben S. Montero 2010-11-19 13:35:07 +01:00
commit 8b75105656

View File

@ -8,6 +8,13 @@ module OpenNebula
NOKOGIRI=false
end
begin
require 'rexml/formatters/pretty'
REXML_FORMATTERS=true
rescue LoadError
REXML_FORMATTERS=false
end
###########################################################################
# The XMLElement class provides an abstraction of the underlying
# XML parser engine. It provides XML-related methods for the Pool and
@ -176,17 +183,20 @@ module OpenNebula
end
def to_xml(pretty=false)
if NOKOGIRI
@xml.to_xml
if NOKOGIRI && pretty
str = @xml.to_xml
elsif REXML_FORMATTERS && pretty
str = String.new
formatter = REXML::Formatters::Pretty.new
formatter.compact = true
formatter.write(@xml,str)
else
str = ""
if pretty
REXML::Formatters::Pretty.new(1).write(@xml,str)
else
REXML::Formatters::Default.new.write(@xml,str)
end
str
str = @xml.to_s
end
return str
end
end