@return [Hash] Returns the rules for this xml parser that define
how it should transform the XMl into Ruby.
@param [Hash] rules A has of xml parsing rules. Generally
rules will come from an xml grammar.
# File lib/aws/core/xml/parser.rb, line 21 def initialize rules = {} @rules = rules end
@param [String] xml An XML document string to parse. @param [Hash] rules A has of xml parsing rules. Generally
rules will come from an xml grammar.
@return [Hash] Returns a hash of parsed xml data.
# File lib/aws/core/xml/parser.rb, line 45 def self.parse xml, rules = {} self.new(rules).parse(xml) end
@param [String] xml An XML document string to parse. @return [Hash] Returns a hash of parsed xml data.
# File lib/aws/core/xml/parser.rb, line 31 def parse xml xml = '<xml/>' if xml.nil? or xml.empty? sax_handler.parse(xml) end
@return [Hash] Returns a hash of mostly empty placeholder data.
# File lib/aws/core/xml/parser.rb, line 37 def simulate XML::Stub.simulate(rules) end
There are three handlers, nokogiri is the fastest, followed by libxml-ruby. Lastly (by a long shot) is REXML. REXML is the only library that does not rely on a native extension.
Currently you can not choose your xml sax handler, and the only we express a gem dependency on is nokogiri.
# File lib/aws/core/xml/parser.rb, line 59 def sax_handler begin SaxHandlers::Nokogiri.new(rules) rescue NameError, LoadError SaxHandlers::REXML.new(rules) end end