
Figure 7.8: Running the conversion utility
You recognize many elements from the previous listing. The novelty is in
functions
walkNode() and walkProduct().
walkNode() is very similar to searchPrice(). It walks down the tree looking
for product elements. When it finds a product, it calls walkProduct().
walkProduct() is a specialized function that processes only product ele-
ments. However, by virtue of being specialized, it knows that a product ele-
ment contains a name element and a price element. It therefore extracts
information from both the name and the price elements. This function
maintains state information: It knows it is in a product element ...