This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Digester Problem  RSS feed

Neha Kathuriaa
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!