onload="start()"
>
tag. start() then
passes visit(...) the first element, the documentElement, and then visit(...) takes over.
- 137 -
visit(...) checks if the node that is passed to it is an Element node; if so, the tag name for
the element is displayed to the user through an alert box. The function then performs the
same action on the children with a depth-first traversal of the tree. Depth-first means that
the function goes as deep as possible before visiting siblings. The other type of traversal
is referred to as a breadth-first traversal, where all the siblings are first visited and then
the children.
|