Skip to content

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

iXML Library - Streams and Documents

Other versions: 7.31 | 7.40 | 7.54

Input Streams and Output Streams

Input streams are used for the input of XML data into the parser and output streams are used to pass XML data from the renderer. A factory is needed to create a stream, which can be created using the iXML factory as follows:

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

The static type of the reference variable stream_factory is then the interface IF_IXML_STREAM_FACTORY, which contains factory methods CREATE_ISTREAM_... for input streams and CREATE_OSTREAM_... for output streams.

Different streams can be created for different data sources and data sinks, such as strings, internal tables, or files specified by URI.


  • iXML input streams can be specified as an XML source and iXML output streams can be used as an XML target for XSL transformations called using CALL TRANSFORMATION.

  • If output streams are bound to internal tables with byte-like row type, the last row is not usually filled completely with content from the stream. The length of the actual data in the row can be determined using the return value of the method GET_NUM_WRITTEN_RAW of the output stream modulo the number of table rows.


The XML result of a transformation of an ABAP data object to the asXML format is used to create an iXML input stream. This stream is then transformed back again.

                       RESULT XML DATA(xml_string).

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

DATA  result TYPE string.
                       RESULT text = result.

XML documents

Each XML saved in DOM format in the memory is managed using a separate object. An object of this type can be created as follows:

DATA(ixml) = cl_ixml=>create( ).
DATA(document)       = ixml->create_document( ).

The static type of the reference variable stream_factory is also IF_IXML_DOCUMENT. A document created in this way

  • is used to address an XML document saved as DOM,
  • can be bound to the parser to fill it,
  • can be used to construct new XML data or modify existing data,
  • can be passed to the renderer to produce the output of the renderer.


iXML documents can be defined as an XML target, iXML documents and their nodes can be specified as an XML source for XSL transformations called using CALL TRANSFORMATION.


Creates a document and uses it as the XML target of an XSL transformation. The filled document is then passed to a renderer (to which an output stream for a character string is bound simultaneously) and rendered. The character string then contains the character-like representation of the XML data.

DATA(ixml)  = cl_ixml=>create( ).
DATA(document)       = ixml->create_document( ).

                       RESULT XML document.

DATA xml_string TYPE string.
ixml->create_renderer( document = document
                       ostream  = ixml->create_stream_factory(
                                         string = xml_string )
                                           )->render( ).