java - XStream - loading custom XML -
i'm trying load xml file of following format:
<?xml version="1.0" encoding="iso-8859-1"?> <mycompany> <record> <surname> bird </surname> <given1> andrew </given1> <id> 225958 </id> <birthdate> 260391 </birthdate> <peeryear> 2009 </peeryear> <title> </title> <preferred> andrew </preferred> <given2> macarthur </given2> <countryofbirthcode> aus </countryofbirthcode> <nationalitycode> </nationalitycode> <occupcode> retired </occupcode> <suburb> metung </suburb> <state> vic </state> <postcode> 3904 </postcode> <countrycode> aus </countrycode> <phone> </record>
i try read, not write format, i've set aliases as:
m_xstream.alias("mycompany", mycompany.class); m_xstream.alias("record", record.class);
where mycompany is:
public class mycompany { @xstreamimplicit public list<record> records = new arraylist<record>(); }
and record class public member variables ala:
public class record { public string id; public string surname; }
when try read above xml, doesn't read mycompany.records member variable.
what correct way read xml and, also, how ignore elements member variable not present?
thank you.
to process @xstreamimplicit
annotation in mycompany
need call first:
m_xstream.processannotations(mycompany.class);
or instead of annotation can this:
m_xstream.addimplicitcollection(mycompany.class, "records");
Comments
Post a Comment