Chapter 12. The DOM Traversal Module


The examples in Chapters 9 to 11 duplicated quite a bit of tree-walking code. Some of them searched for particular information. Others modified documents in memory. What they all had in common was that they navigated a tree from the root to the deepest leaf element in document order. This is an extremely common pattern in DOM programs.

The org.w3c.dom.traversal package is a collection of utility interfaces that implement most of the logic needed to traverse a DOM tree. These include NodeIterator , NodeFilter , TreeWalker , and DocumentTraversal . DOM implementations are not required to support these interfaces, but many do, including the Oracle XML Parser for Java and Xerces. (Crimson does not. GNU JAXP supports NodeIterator but not TreeWalker .) By reusing these classes you can simplify your programs a great deal and save yourself a significant amount of work.



Processing XML with Java. A Guide to SAX, DOM, JDOM, JAXP, and TrAX
Processing XML with Javaв„ў: A Guide to SAX, DOM, JDOM, JAXP, and TrAX
ISBN: 0201771861
EAN: 2147483647
Year: 2001
Pages: 191

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net