You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Miguel Angel JĂșlvez <ma...@grupocomex.com> on 2008/12/09 18:13:21 UTC
[betwixt]sub-tree xml file to beans collection
Hi!!!
I've a xml file so:
<pruebas>
<prueba>
<idPrueba>1</idPrueba>
<name>nameBean</name>
</prueba>
<prueba>
<idPrueba>2</idPrueba>
<name>nameBean</name>
</prueba>
</pruebas>
What can i do to get that betwixt reads this xml file??
I've tried with a class beans:
public class Pruebas extends BaseBean implements Serializable, Cloneable
{
protected Prueba[] pruebas;
public Pruebas() {
pruebas = new Prueba[5];
for (int i = 0; i<pruebas.length; i++) {
pruebas[i] = null;
}
}
public Object clone() {
Pruebas nuevo = (Pruebas)super.clone();
nuevo.pruebas = pruebas;
return nuevo;
}
public Prueba[] getPruebas() {
return pruebas;
}
public void addPrueba(Prueba prueba) {
System.out.println("pruebas");
for (int i=0; i<pruebas.length; i++) {
if (pruebas[i] == null) {
pruebas[i] = prueba;
}
}
}
and addPrueba() method isn't call never
By the way, I use betwixt this way:
BeanReader beanReader = new BeanReader();
beanReader.registerBeanClass(Pruebas.class);
InputSource a = new InputSource(xmlReader);//Where xmlReader is the xml
content as string
beanReader.getXMLIntrospector().register(a);
Pruebas pruebas = (Pruebas) beanReader.parse(a);
System.out.println(pruebas);
And nothing is printed.
Anyone can help me???
Thanks!!
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org