| Class | REXML::Parsers::PullParser |
| In: |
rexml/parsers/pullparser.rb
|
| Parent: | BaseParser |
This API is experimental, and subject to change.
parser = PullParser.new( "<a>text<b att='val'/>txet</a>" ) while parser.has_next? res = parser.next puts res[1]['att'] if res.start_tag? and res[0] == 'b' end
See the PullEvent class for information on the content of the results. The data is identical to the arguments passed for the various events to the StreamListener API.
Notice that:
parser = PullParser.new( "<a>BAD DOCUMENT" ) while parser.has_next? res = parser.next raise res[1] if res.error? end
Nat Price gave me some good ideas for the API.
# File rexml/parsers/pullparser.rb, line 29 def initialize stream super @entities = {} @listeners = nil end
# File rexml/parsers/pullparser.rb, line 35 def add_listener( listener ) @listeners = [] unless @listeners @listeners << listener end