commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergio Cuenca <correo.cue...@gmail.com>
Subject Re: Reading XML as bean collection using Betwixt
Date Wed, 06 Mar 2013 10:58:28 GMT
Ravindra Wankar <rwankar <at> celoxis.com> writes:

> 
> 
> How do I convert an XML to bean collection?
> 
> XML:
> <persons>
>     <person>
>         <name>A</name>
>         <age>21</age>
>     </person>
>     <person>
>         <name>B</name>
>         <age>25</age>
>     </person>
>     <person>
>         <name>C</name>
>         <age>32</age>
>     </person>
> </persons>
> 
> Java code:
> 
> beanReader.registerBeanClass("persons",  ArrayList.class);
> beanReader.registerBeanClass("persons/person",  Person.class);
> ArrayList persons = (ArrayList)beanReader.parse(xmlReader);
> 
> I get an empty list. I'm using Betwixt 0.8, Digester 1.8, BeanUtils 1.7
> 
> Thanks
> - Ravi.
> 


Hi,

In my case I must define the adder method in the betwixt file, like this:

<?xml version="1.0" encoding="UTF-8" ?>
<info primitiveTypes="element">
    <element name='record-bean'>
		<element name='name' property='name' />    	
           
		<element name='changes'>
			<element name='change' property='changes' 
updater='addChanges'>
				<element name='change_detail' 
class='com.logister.sample.Change'/>
			</element>	
      	</element>
    </element>
</info>

Hope this helps.
Regards.




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


Mime
View raw message