File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes Digester Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Digester Problem" Watch "Digester Problem" New topic

Digester Problem

Neha Kathuriaa

Joined: Sep 16, 2008
Posts: 25
I have to create a simple digester class .I tried the following example given on Apache site.
package mypackage;
public class Foo {
public void addBar(Bar bar);
public Bar findBar(int id);
public Iterator getBars();
public String getName();
public void setName(String name);
package mypackage;
public class Bar {
public int getId();
public void setId(int id);
public String getTitle();
public void setTitle(String title);
and you wish to use Digester to parse the following XML document:
<foo name="The Parent">
<bar id="123" title="The First Child"/>
<bar id="456" title="The Second Child"/>
A simple approach will be to use the following Digester in the following way to set up the parsing rules, and then process an input file containing this document:

Digester digester = new Digester();
digester.addObjectCreate("foo", "mypackage.Foo");
digester.addObjectCreate("foo/bar", "mypackage.Bar");
digester.addSetNext("foo/bar", "addBar", "mypackage.Bar");
Foo foo = (Foo) digester.parse();
This was working for me. Now I want to create a digester class which can read tags from xml file. But I don't want to give the matching patterns like this digester.addObjectCreate("foo", "mypackage.Foo");I want to read all the custom tags in xml in generakized manner.Can anybody give me a solution to this?
I agree. Here's the link:
subject: Digester Problem
It's not a secret anymore!