I've been using a slightly simpler method than Craig's to get the body 
content. I use this:

digester.addCallMethod("database/user/text", "setText", 0);

I got the idea for this from the JavaDoc comment for addCallMethod, which 
says that specifying zero for the parameter count means "a single parameter 
from the body of this element".

I don't know if there's any practical difference, other than being one line 
of code instead of two. :-)

--
Martin Cooper
Tumbleweed Communications


At 01:40 PM 2/9/01 -0800, Craig R. McClanahan wrote:
>Jens Rehpöhler wrote:
>
> > Hello Steven,
> >
> > I think I didn't described my problem correctly. Parsing the properties 
> of a tag works
> > well. But I want to parse the content between some tags. For example:
> >
> > <database>
> >     <user propertie="name">
> >         <text>this is the value i want to initialize my class with</text>
> >     </user>
> > </database>
> >
> > With the addSetProperties method I can parse the propertie of the user 
> tag, but I
> > can't parse the content between the <text> tag.
>
>The rules that are *supposed* to work for this would be:
>
>     digester.addCallMethod("database/user/text", "setText", 1);
>     digester.addCallParam("database/user/text", 0);
>
>Translated into English, these rules state that, whenever the specified 
>pattern is
>encountered:
>* Set up a call to the setText(String text) method of the
>   object on the top of the call stack
>* Set the zeroth parameter (i.e. the only one) to the
>   body content of this element
>
>With other variations of the addCallParam() method, you can take parameter 
>values from
>certain attributes of this element as well.
>
>Craig McClanahan


Reply via email to