1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
require "nokogiri"
module Fog
module Parsers
class Base < Nokogiri::XML::SAX::Document
attr_reader :response
def initialize
reset
end
def attr_value(name, attrs)
(entry = attrs.find {|a| a.localname == name }) && entry.value
end
def reset
@response = {}
end
def characters(string)
@value ||= ''
@value << string
end
# ###############################################################################
# This is a workaround. Original implementation from Nokogiri is overwritten with
# one that does not join namespace prefix with local name.
def start_element_namespace name, attrs = [], prefix = nil, uri = nil, ns = []
start_element name, attrs
end
def end_element_namespace name, prefix = nil, uri = nil
end_element name
end
# ###############################################################################
def start_element(name, attrs = [])
@value = nil
end
def value
@value && @value.dup
end
end
end
end
|