ABAP Keyword Documentation →  ABAP − Reference →  Data Interfaces and Communication Interfaces →  ABAP and XML →  Class Libraries for XML →  iXML Library →  iXML Library - Parse → 

iXML Library - Complete Parse to DOM

To parse XML data to a DOM representation in a single action, a dedicated parser is used as follows:

DATA(rc) = parser->parse( ).

Here, parser is a reference variable that points to the parser. The parser checks whether the XML data of the input stream istream is correct and creates a DOM representation of this file in the memory. The return value of the method PARSE has the type i and uses values to produce the result that match the following constants from the type group IXML:

If the parsing is successful, the XML document document associated with the parser can be used to access the DOM saved in the memory.

Notes

Example

Creates a parser for an input stream for a text string and parses it to an XML document.

DATA(ixml)  = cl_ixml=>create( ).
DATA(stream_factory) = ixml->create_stream_factory( ).

DATA(istream)        = stream_factory->create_istream_string(
  `<?xml version="1.0"?>`         &&
  `  <text>`                      &&
  `    Mer lasse de DOM in Kölle` &&
  `  </text>` ).

DATA(document)       = ixml->create_document( ).
DATA(parser) = ixml->create_parser(
                         stream_factory = stream_factory
                         istream        = istream
                         document       = document ).

DATA(rc) = parser->parse( ).

IF rc <> ixml_mr_parser_ok.
  ... "Error handling
  RETURN.
ENDIF.