ABAP - Keyword Documentation →  ABAP - Programming Language →  Data Interfaces and Communication Interfaces →  ABAP and XML →  XML - Class Libraries →  iXML Library →  iXML - Access to DOM →  iXML - DOM Reads → 
Mail Feedback

iXML - Reads Using Filters

When a DOM is read using iterators, all nodes of a document or subtree or all elements of a list are read by default. A filter can be linked with an iterator to restrict it to specific nodes or elements only. Filters can be created using factory methods from the interface IF_IXML_NODE. For example, a condition can be set for the name of an element as follows if document has the type IF_IXML_DOCUMENT and points to an XML:

DATA(filter) = document->create_filter_name_ns( name = ... ).

The static type of the reference variable filter is then IF_IXML_NODE_FILTER and the variable points to a filter object that can be passed to an iterator as follows:

DATA(iterator) = document->create_iterator( ).
...
iterator->set_filter( filter ).

or in short

DATA(iterator) = document->create_iterator_filtered( filter ).

The iterator then only reads elements of the name passed to the filter. The factory methods of the interface for nodes can be used to create the following filters (among others):

Other factory methods are available for associating multiple filters and creating special filters that implement Boolean operators:

References to existing filter objects can be passed to the input parameters of these factory methods. A new filter is created that implements the Boolean operator on the passed filters.

Hint

For more information (further filters and possible parameters), see the interface IF_IXML_NODE.

Executable Example

Iterator Filters