ARTICLE
iXML Library - Sequential Parsing
To parse XML data sequentially, a dedicated
parser is called multiple times as
follows:
DATA(event) = parser- parse_event( ).
Here, parser is a reference variable that points to the parser.
The method PARSE_EVENT returns a reference variable with the type
IF_IXML_EVENT that points to an
object representing an event that occurred during parsing. The parser
processes the input stream
istream in sequences defined by the events for which the caller
registered itself earlier. The possible events are saved as constants
co_event... in the interface
IF_IXML_EVENT . They are registered using the method
parser->set_event_subscription( events = if_ixml_event=>co_event...
+
if_ixml_event=>co_event... +
... ).
The parser pauses after every event registered like this and uses the
object referenced by event to return the properties of the
current sequence. The method PARSE_EVENT must be called again to
edit the next sequence. If all XML data was parsed or if an error
occurred, the return value of PARSE_EVENT is initial.
By default, DOM -based XML documents are constructed bit by
bit in the memory during sequential processing. Once processing is
complete, they are available in the same ways as after the method
PARSE .
Troubleshooting is also similar.
During sequential parsing, the document represents a valid XML
document with the elements parsed up until now. If sequential parsing is
ended before all elements in the input stream have been processed, the
XML document represents the part of the input stream parsed up
until now. The method SET_DOM_GENERATING of the parser can be
used to switch the generation of the DOM representation off.
Notes
A parsing event is not an event triggered by EVENTS
in ABAP Objects; it is an iterator concept.
If the caller does not register any events before PARSE_EVENT is
called, PARSE_EVENT works like PARSE .
The sequential parsing shown here is not a variant of SAX (
Simple API for XML ). Callback methods are not called when an
event occurs.
Example
See iXML Library,
Sequential Parsing .
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved