SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Class Libraries for XML → iXML Library → iXML Library, Examples →iXML Library, Filter for Iterator
Filtered access to nodes in DOM using an iterator.
Source Code
REPORT demo_ixml_filter_iterator.
CLASS ixml_demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS ixml_demo IMPLEMENTATION.
METHOD main.
DATA source_tab TYPE TABLE OF i.
DO 10 TIMES.
APPEND ipow( base = 2 exp = sy-index ) TO source_tab.
ENDDO.
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(iterator) = document->create_iterator_filtered(
document->create_filter_and(
filter1 = document->create_filter_node_type(
node_types = if_ixml_node=>co_node_element )
filter2 = document->create_filter_name_ns(
name = 'item' ) ) ).
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
Writes XML data created in asXML format using an XSL transformation directly to an XML document in DOM representation. An iterator is created for the full document, associated with a filter. The filter is an "and" join between two filters and selects by node type and name. The iterator only returns the selected nodes.