Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added parser for stdlib xmlrpc library #86

Merged
merged 1 commit into from

2 participants

@jfontan

Parser adapter for stdlib xmlrpc. Related to ohler55/ox#84.

@ohler55 ohler55 merged commit f859c20 into ohler55:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 14, 2014
  1. @jfontan
This page is out of date. Refresh to see the latest.
Showing with 32 additions and 0 deletions.
  1. +32 −0 lib/ox/xmlrpc_adapter.rb
View
32 lib/ox/xmlrpc_adapter.rb
@@ -0,0 +1,32 @@
+
+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
+ def initialize
+ @parser_class = OxParser
+ end
+
+ class OxParser < Ox::Sax
+ include XMLRPC::XMLParser::StreamParserMixin
+
+ alias :text :character
+ alias :end_element :endElement
+ alias :start_element :startElement
+
+ def parse(str)
+ Ox.sax_parse(self, StringIO.new(str), :symbolize => false)
+ end
+ end
+ end
+end
Something went wrong with that request. Please try again.