3
(c) 1998-2003 (W3C) MIT, ERCIM, Keio University
4
See tidy.h for the copyright notice.
6
These files contain utility routines to perform in-order traversals of the
7
Tidy document tree, beginning at an arbitrary node.
9
A traversal of the tree can be performed in a manner similar to the following:
12
TidyNodeIter *iter = newTidyNodeIter( FindBody( tdoc ));
13
for (testNode = nextTidyNode( &iter );
15
testNode = nextTidyNode( &iter ))
19
TODO: Add a prevTidyNode() function.
24
typedef struct _TidyNodeIter
26
Node *pTop, *pCurrent;
29
TidyNodeIter *newTidyNodeIter( Node *pStart );
32
nextTidyNode( TidyNodeIter *pIter )
34
if pCurrent is NULL, this function initializes it to match pTop, and
35
returns that value, otherwise it advances to the next node in order,
36
and returns that value. When pTop == pCurrent, the function returns NULL
37
to indicate that the entire tree has been visited.
39
Node *nextTidyNode( TidyNodeIter *pIter );
42
setCurrentNode( TidyNodeIter *pThis, Node *newCurr )
44
Resets pCurrent to match the passed value; useful if you need to back up
45
to an unaltered point in the tree, or to skip a section. The next call to
46
nextTidyNode() will return the node which follows newCurr in order.
48
Minimal error checking is performed; unexpected results _will_ occur if
49
newCurr is not a descendant node of pTop.
51
void setCurrentNode( TidyNodeIter *pThis, Node *newCurr );