It also has to do with your class structure and your xml.
I haven't tested this, but try this....
public class User {
private Tagwithbody twb = null;
public void setTagwithbody(Tagwithbody theClass) { twb = theClass; }
public Tagwithbody getTagwithbody() { return twb; }
}
public class Tagwithbody {
private String attribute = null;
public void setAttribute(String in) { attribute = in; }
public String getAttribute() { return attribute; }
}
<database>
<user username="Joe">
<tagwithbody attribute="something">
</tagwithbody>
</user>
</database>
digester.addObjectCreate("database/user", "model.User");
digester.addSetProperties("database/user");
digester.addSetNext("database/user", "addUser");
// rule to create instance of Tagwithbody class that is an attribute in User
class called twb
digester.addObjectCreate("database/user/tagwithbody", "model.Tagwithbody",
"twb");
// this sets the attribute in Tagwithbody class
digester.addSetProperties("database/user/tagwithbody");
// rule to call setTagwithbody method on User class, takes type of
model.Tagwithbody
digester.addSetNext("database/user/tagwithbody",
"setTagwithbody","model.Tagwithbody");
Steve
Jens Rehpöhler wrote:
>
> Hi all,
>
> I'm trying to read the body content of a xml tag with the Digester class. By
> using the standard methods from the class I only get an empty String. Here's the
> example code (i justed played around with the user database from the struts
> example):
>
> Digester Code:
>
> // this works fine
> digester.addObjectCreate("database/user", "model.User");
> digester.addSetProperties("database/user");
> digester.addSetNext("database/user", "addUser");
>
> // here i get only an empty string
> digester.addObjectCreate("database/user/tagwithbody", "java.lang.String");
> digester.addSetNext("database/user/tagwithbody", "setTagwithbdoy");
>
> What I am missing is a method called something like
>
> digester.addSetBody("database/user/tagwithbody");
>
> after the addObjectCreate method.
>
> The setTagwithbody method is part of the User class.
>
> Jens
--
-----------------------------------------------------------------
Steven D. Wilkinson, [EMAIL PROTECTED]