ARTICLE
iXML Library, 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 associated 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):
CREATE_FILTER_NODE_TYPE : Condition for the type of a node
CREATE_FILTER_NAME_NS : Condition for the name of a node
CREATE_FILTER_ATTRIBUTE_NS : Condition for the name and value of
an attribute
Other factory methods are available for combining multiple filters and
creating special filters that implement Boolean operators:
CREATE_FILTER_AND : "and" join
CREATE_FILTER_OR : "or" join
CREATE_FILTER_NOT : Negation
References to existing filter objects can be passed to the input
parameters of these factory methods. A new filter is created that i
mplements the Boolean operator on the filters in question.
Note
For more information (about further filters and possible parameters),
see the interface IF_IXML_NODE .
Example
See Filters for Iterator
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved