dom4j visitor pattern walk
- Preparation -- Use the walk method in the os.path module to
list/print the names of the directories and files in a
directory/sub-directory hierarchy.
- Use the dom4j visitor pattern support to visit all the nodes in an
XML document.
- Print out a bit of information about each node, e.g. the node/tag
name.
- Check the type of the node, and print out only information on
specific node types, for example, only element nodes or only text
nodes.
- Add a counter to your visitor. Initialize the counter in your
visitor class constructor. Increment and display the counter with
each node.
What you will learn:
- How to use the visitor pattern.
- More on using dom4j.
- How to use the dom4j visitor pattern to walk over all the nodes in a
document.
Question: Can you find a difference or deficiency in the visitor
pattern when used from Jython rather than Java? Hint: How would you
visit only Element nodes?
Additional information: