Ruby, Rails, Firefox, Anime, Mac
In: Java28 May 2003
The Digester component of the Jakarta Commons project is an extremely useful and well-designed package that allows you to parse XML files at a higher level of abstraction in Java. This allows developers to concentrate on processing XML rather than get unnecessarily involved in parsing functions. With Digester, you can use simple matching patterns and write corresponding callback functions which are called whenever a match is found. For example, consider the XML snippet below.
<book> <title>The Hobbit</title> <author>J. R. R. Tolkien</author> </book>
In Digester, you can write this (in Java):
Digester digester = new Digester();
When Digester parses the XML file (assumed to be “books.xml”), it will create a Book object when it encounters the