Sha256: b8f8f06c6c89b1fe9514c01ec76b4a590d5334eac89b04a060f30ddfbfb78b8e

Contents?: true

Size: 943 Bytes

Versions: 6

Compression:

Stored size: 943 Bytes

Contents

require 'ox'

module Ox
  # This is an alternative parser for the stdlib xmlrpc library. It makes
  # use of Ox and is based on REXMLStreamParser. To use it set is as the
  # parser for an XMLRPC client:
  #
  #   require 'xmlrpc/client'
  #   require 'ox/xmlrpc_adapter'
  #   client = XMLRPC::Client.new2('http://some_server/rpc')
  #   client.set_parser(Ox::StreamParser.new)
  class StreamParser < XMLRPC::XMLParser::AbstractStreamParser
    # Create a new instance.
    def initialize
      super
      @parser_class = OxParser
    end

    # The SAX wrapper.
    class OxParser < Ox::Sax
      include XMLRPC::XMLParser::StreamParserMixin

      alias text character
      alias end_element endElement
      alias start_element startElement

      # Initiates the sax parser with the provided string.
      def parse(str)
        Ox.sax_parse(self, StringIO.new(str), symbolize: false, convert_special: true)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ox-2.14.22 lib/ox/xmlrpc_adapter.rb
ox-2.14.21 lib/ox/xmlrpc_adapter.rb
ox-2.14.20 lib/ox/xmlrpc_adapter.rb
ox-2.14.19 lib/ox/xmlrpc_adapter.rb
ox-2.14.18 lib/ox/xmlrpc_adapter.rb
ox-2.14.17 lib/ox/xmlrpc_adapter.rb