For trees of unknown depth we must sometimes use recursive routines to extract data. We have such a file in yahoo.xml which, as you might imagine, could be pretty deep.
The function walkover takes a node n as input. The other parameter x gives the depth of the node. We visit each node, then visit each if the children in turn. This is a "pre-order" walk. We visit the parent before we visit the children.
-, try writing this instead of the number i. Like this.
This time the s parameter builds up the path of the node so far.
Science, Astronomy
and Cosmology are given
as the id attributes for the corresponding nodes.
Use this to create linked words.
Like this