<b>(a)</b> if (nodeAdapter.hasChildren( node) && depth<=maxDepth) // go to children's level ... <b>(b)</b> public static final int idLevel = 2; //... Document xdoc = parser.readStream(new FileReader( "personnel.xml")); TIterator tIterator = new TIterator ( xdoc , new DOMAdapter(), idLevel ); for( Node node = xdoc; node!=null; node=(Node)tIterator.next() ){ // perform processing... }
Example 3: The tree iterator stops at the second level and does not go any deeper.