Class | XMLStreamin::XMLStreamListener |
In: |
xmlstreamin.rb
|
Parent: | Object |
This class extends REXML::StreamListener to provide an interface to a ‘tree’ of XMLSpec nodes that models the hierarchy of the XML document to be read.
Create a new XMLStreamListener with root as the root XMLSpec of the XML hierarchy to be parsed. base is an optional ‘context’, of any form suitable to the task, that will be passed to all XMLSpec methods invoked.
Invoked when a CDATA tag is encountered in the document, with the content as argument. The current XMLSpec#cdata method is in turn called.
Invoked when the end tag is reached, with the name of the tag as argument. In the case of an empty tag (’<tag/>’, tag_end will be called immediately after tag_start. If the element was not empty, the current XMLSpec#done method is called, otherwise the XMLSpec#empty method. Then the previous higher level) spec is restored.
Invoked when a tag is encountered, with args:
<tag attr1="value1" attr2="value2">
will result in: tag_start( "tag", {"attr1"=>"value1","attr2"=>"value2"})
This in turn determines the appropriate XMLSpec node that should handle the tag (by querying the current spec), sets this as the new current spec, and invokes its XMLSpec#start method.
Invoked when text is encountered in the document, with the text content as argument. The current XMLSpec#text method is in turn called. (Note that if the text is interspersed with other elements, this method is invoked for each segment separately.)