Skip to content

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

iXML Library

Other versions: 7.31 | 7.40 | 7.54

API of the iXML Library

iXML Library provides an API for handling XML documents in DOM format. This API enables

  • XML data to be parsed to DOM format,
  • reads and writes to be performed on XML documents in DOM format (including creating new documents),
  • XML documents in DOM format to be rendered to XML data.

In ABAP programs, the API is implemented using interfaces from the class library with the naming convention IF_IXML_.... The access class CL_IXML contains factory methods for creating objects such as streams, parsers, documents, and renderers. These objects are then accessed using interface reference variables. The classes and interfaces are documented in Class Builder.


Notes

  • The classes and interfaces in iXML Library in package SIXML wrap classes and interfaces implemented in C++, delivered as part of the ABAP kernel.

  • Standalone versions for C++ and C are also delivered, with the C version being a wrapper of the library implemented in C++.

  • iXML Library supports the Unicode character format UCS-2. Characters from the surrogate area are not supported and can be rejected as invalid.

Access to iXML Library.

Precisely one factory object of the access class CL_IXML is required for accessing iXML Library in an ABAP program. This object is created as follows:

DATA(ixml) = cl_ixml=>create( ).

The static type of the reference variable ixml is then the interface IF_IXML, which contains all factory methods required to create further objects, such as streams, XML documents, parsers, or renderers. This factory object is a singleton and can only be instantiated once in one internal session.

Services in the iXML Library

The most important services offered by the classes and interfaces in iXML Library are as follows:

The XML parser analyzes the syntax of an XML file provided in an input stream to check whether it is correct and creates an XML document in a DOM representation from this file. The document can then be accessed using interfaces. The DOM can be created as follows:
  • Complete Parsing to DOM
    The parser creates the XML document in a DOM representation for the complete XML data in a single action and passes it to the memory.
  • Sequential Parsing
    The parser processes the input stream in sequential actions, where each sequence is determined by events that can be accessed using the interface IF_IXML_EVENT. The application can edit each sequence while the parser is running. It is possible to configure whether a full XML documented is saved to DOM representation.
  • Parsing to Data Objects
    When parsing to data objects, the tokens of the parsed XML data is written directly to ABAP data objects (structures, internal tables). An XML document in DOM representation can also be saved.
An XML document represented as DOM is in a standardized tree representation. For each logical unit of the XML document, there is a node object of an associated class that implements specialized interfaces. An ABAP program can use the interfaces to perform reads and writes to the XML document. The classes of the node objects are not usually used directly in the program.
The XML renderer creates XML data from an XML document saved as DOM. This document is created by parsing (both with and without follow-up modifications) or created as a complete new document using the methods of the DOM interface. The renderer then passes the data to an output stream.


Notes

  • One benefit of DOM is simple access to the individual parts of an XML document. It also has the drawback, however, of using more memory, up to ten times the actual size of the document. Note that the document itself can already use more memory for its markup than for the actual data. This memory use can be restricted by preventing a complete DOM from being created by sequential parsing or by parsing to data objects.

  • The DOM in iXML Library also includes DTDs (Document Type Definitions).

  • If XML data needs to be parsed and rendered only and no XML documents in DOM representation and no DTDs are needed, sXML Library provides an alternative with better performance than iXML Library.

  • iXML only supports the XML 1.0 format, where, XML data is represented in a particular character format using a character string. sXML Library supports more formats.

  • When data is rendered as character-like XML data, this data is prefixed by the byte order mark (BOM) that is required by the XML standard.

Continue

iXML Library - Streams and Documents

iXML Library - Parsing

iXML Library - Access to DOM

iXML Library - Render

iXML Library - Classes and Interfaces

iXML Library, Examples