| Class | REXML::Parsers::UltraLightParser |
| In: |
lib/rexml/parsers/ultralightparser.rb
|
| Parent: | Object |
# File lib/rexml/parsers/ultralightparser.rb, line 7
7: def initialize stream
8: @stream = stream
9: @parser = REXML::Parsers::BaseParser.new( stream )
10: end
# File lib/rexml/parsers/ultralightparser.rb, line 12
12: def add_listener( listener )
13: @parser.add_listener( listener )
14: end
# File lib/rexml/parsers/ultralightparser.rb, line 21
21: def parse
22: root = context = []
23: while true
24: event = @parser.pull
25: case event[0]
26: when :end_document
27: break
28: when :end_doctype
29: context = context[1]
30: when :start_element, :doctype
31: context << event
32: event[1,0] = [context]
33: context = event
34: when :end_element
35: context = context[1]
36: else
37: context << event
38: end
39: end
40: root
41: end