commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luke Shannon" <>
Subject Re: [digester] concatenate multiple elements to a property
Date Wed, 16 Feb 2005 15:20:10 GMT
I'm a Digester newbie, but I will take a crack at this because it looks like
something I recently did.

Here is a digester method that would put all of the string-elements into a
StringBuffer and return that StringBuffer.

public static Vector digestDocument(File parseMe) throws IOException,
SAXException {
   Digester digester = new Digester();
    //put a string buffer on the stack
  digester.addObjectCreate("elementlist/element", StringBuffer.class);
    //call the append method on the string-element pattern
  digester.addCallMethod("elementlist/element/string-element", "append", 1);
    //the contents of the tag as the parameter to append
  digester.addCallParam("elementlist/element/string-element", 0);
  return (StringBuffer)digester.parse(parseMe);


You could do something like this to set your object property.


Hopefully this makes sense.


----- Original Message ----- 
From: "Stefan Burkard" <>
To: <>
Sent: Wednesday, February 16, 2005 9:57 AM
Subject: [digester] concatenate multiple elements to a property

> hi there
> i'd like to concatenate multiple strings from several xml-elements (for
> example all "stringelement"-values from the example-xml below) to one
> string and add this string to an objectproperty. is this possible with
> digester? has anybody a tip or a code example for me?
> thanks and greetings
> stefan
> <elementlist>
>      <element>
>          <string-element></string-element>>
>          <other elements></other elements>
>      </element>
>      <element>
> above
>      </element>
> </elementlist>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message