You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by simon <si...@chello.at> on 2007/08/20 21:47:28 UTC

Re: [Digester] How to get element values from multiple xml documents

On Mon, 2007-08-20 at 11:49 +0200, Amit wrote:
> Hi All,
> 
> I am using Digester to parse xml document. My xml document looks as follows
> 
> <addresses>
> <address id="1">
> <street>street 1</street>
> <city>city 1</city>
> </address>
> <address id="2">
> <street>street 2</street>
> <city>city 2</city>
> </address>
> </addresses>
> 
> I create a javabean class with attributes street and city. Now every time I
> parse this file with digester I set the values of these attributes.
> The problem is everytime I parse the javabean is set with the last <address>
> attributes here street 2 and city 2 and hence the first and consecutive
> <address> values are overwritten. How can I make every <address> element
> stored or accessible without getting overwritten..?
> Any help appreciated.

You haven't posted your code or your digester rules so I can only guess
what you're doing wrong.

Do you have an object (a List or a custom object) to hold the two
different address objects you create, and define a rule to add created
address objects into it? Digester won't do this for you..

See the examples here for more help:

http://svn.apache.org/repos/asf/commons/proper/digester/trunk/src/examples/

Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org