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

Merge pull request #1442 from deepj/xenserver-nokogiri

[xenserver] Use Nokogiri instead of slow REXML for parsing
This commit is contained in:
Wesley Beary 2013-01-04 12:48:56 -08:00
commit b0113056bd

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