Iteration and tree-walking

The concept of tree-walking (discussed in Chapter 16) is a useful concept when working with a DOM structure. DOM Level 2 supports this concept in a standard way. A new optional package for convenient traversal of document trees has been introduced in this version of the standard. This package includes four interfaces: DocumentTraversal, TreeWalker, Iterator and NodeFilter.

Document traversal interface

There are two ways of traversing a document tree, one more sophisticated than the other. Objects that implement these two approaches can be created on behalf of the application using an object that implements the DocumentTraversal interface.

For example, the Xerces parser includes a class called DocumentImpl that implements ...

Get XML Companion, The, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.