Map XML with same element and attribute names to Java object

tradeofalljacks

New Member
I already searched for this particular issue, the closest thread i found was this one: Java/JAXB: Unmarshall XML elements with same name but different attribute values to different class members But it's still not exactly what i need, so i hope someone can help me with this.I am doing a SOAP request on a Zimbra Collaboration Suite 7 Server to get a contact. The response is something like this:\[code\]<cn fileAsStr="Arthur, Spooner" f="" id="280" rev="1973" d="1338524233000" t="" md="1338524233" ms="1973" l="7"><meta/><a n="homePostalCode">93849</a><a n="lastName">Spooner</a><a n="birthday">1980-05-24</a><a n="homeStreet">Berkleystreet 99</a><a n="firstName">Arthur</a></cn>\[/code\]I want to map this to a Java object, something like this:\[code\]public class Contact {Integer id;Integer rev;String namePrefix;String firstName;String middleName;String lastName;String jobTitle;ArrayList<Adress> adresses;Date birthday;String department;Integer mobilePhone;String email;String company;String notes; ...\[/code\]I usually do this using JAXB, but as all the elements are called a and all the attributes n, I don't know how to map this. I really would appreciate a code snippet or any kind of help. Thanks in advance.
 
Back
Top