ABAP Keyword Documentation → ABAP − Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Class Libraries for XML → iXML Library → iXML Library, Examples
iXML Library, Iterator for Element List
Accesses the nodes in an element list in DOM using an iterator.
Other versions:
7.31 | 7.40 | 7.54
Source Code
REPORT demo_ixml_name_list_iterator.
CLASS ixml_demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS ixml_demo IMPLEMENTATION.
METHOD main.
DATA source_tab TYPE TABLE OF i.
source_tab = VALUE #( FOR j = 1 UNTIL j > 10
( ipow( base = 2 exp = j ) ) ).
DATA(ixml) = cl_ixml=>create( ).
DATA(document) = ixml->create_document( ).
CALL TRANSFORMATION id SOURCE text = `Powers of 2`
numbers = source_tab
RESULT XML document.
DATA(elements) =
document->get_elements_by_tag_name( name = 'item' ).
DATA(iterator) = elements->create_iterator( ).
DATA target_tab LIKE source_tab.
DO.
DATA(node) = iterator->get_next( ).
IF node IS INITIAL.
EXIT.
ENDIF.
APPEND node->get_value( ) TO target_tab.
ENDDO.
cl_demo_output=>display( target_tab ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
ixml_demo=>main( ).
Description
XML data is created in asXML format using the identity transformation and written directly to an XML document in DOM representation. An element list for all elements of the name item is created from this representation and an iterator is created for this list. The elements are extracted using the iterator.