Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Example of actively yielding results from the SAX parser. #78

merged 1 commit into from

2 participants


The existing Ox::Sax example doesn't illustrate the benefit of using a sax parser to yield results actively in stream.


Thanks for the contribution. Busy at work so was slow to merge.

@ohler55 ohler55 merged commit a491425 into ohler55:master

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 32 additions and 0 deletions.
  1. +32 −0
@@ -171,6 +171,38 @@ Ox.sax_parse(handler, io)
# end: top
+### Yielding results immediately while SAX XML Parsing:
+require 'stringio'
+require 'ox'
+class Yielder < ::Ox::Sax
+ def initialize(block); @yield_to = block; end
+ def start_element(name);; end
+io ={
+<top name="sample">
+ <middle name="second">
+ <bottom name="third"/>
+ </middle>
+proc = { |name| puts name }
+handler =
+puts "before parse"
+Ox.sax_parse(handler, io)
+puts "after parse"
+# outputs
+# before parse
+# top
+# middle
+# bottom
+# after parse
### Object XML format
The XML format used for Object encoding follows the structure of the
Something went wrong with that request. Please try again.