A simple program to demonstrate that the Commons Digester module can be used to trigger actions as the xml is parsed, rather than just build up in-memory representations of the parsed data. This example also shows how to write a custom Rule class.
This code will parse the provided "example.xml" file, and immediately insert the processed data into a database as each row tag is parsed, instead of building up an in-memory representation. Actually, in order to keep this example simple and easy to run, sql insert statements are printed out rather than actually performing database inserts, but the principle remains.
Very verbose comments are included here, as this class is intended as a tutorial; if you look closely at method "addRules", you will see that the amount of code required to use the Digester is actually quite low.
Usage: java Main example.xml