1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[xenserver] Use Nokogiri instead of slow REXML for parsing

This commit is contained in:
deepj 2013-01-04 05:41:28 +01:00
parent 4e047e9d30
commit 7172c15472

View file

@ -14,7 +14,7 @@ module Fog
def initialize(host)
@factory = XMLRPC::Client.new(host, '/')
@factory.set_parser(XMLRPC::XMLParser::REXMLStreamParser.new)
@factory.set_parser(NokogiriStreamParser.new)
end
def authenticate( username, password )
@ -50,6 +50,30 @@ module Fog
end
end
class NokogiriStreamParser < XMLRPC::XMLParser::AbstractStreamParser
def initialize
require 'nokogiri/xml/sax/document'
require 'nokogiri/xml/sax/parser'
@parser_class = Class.new(Nokogiri::XML::SAX::Document) do
include XMLRPC::XMLParser::StreamParserMixin
alias_method :start_element, :startElement
alias_method :end_element, :endElement
alias_method :characters, :character
alias_method :cdata_block, :character
def parse(str)
Nokogiri::XML::SAX::Parser.new(self).parse(str)
end
end
end
end
end
end