XML to Java Object with JAXB -


i have got xml file convert java object.

i have looked @ jaxb, xml seems far complex.

here store has same elements nested each other. don't match, , unsure of how create annotation class this.

<?xml version="1.0" encoding="utf-8"?> <store id="1" name="main">     <store id="2" name="xx">         <location>here</location>     </store>     <store id="3" name="xx">         <location>here</location>     </store>     <store id="56" name="xx">         <store id="97" name="xx">             <img>store_image.png</img>             <store id="101" name="five">                 <img>tore_image.png</img>                 <store id="145" name="xx">                     <img>tore_image.png</img>                     <location>here</location>                 </store>                 <store id="252" name="xx">                     <img>store_image.png</img>                     <location>here</location>                 </store>             </store>         </store>     </store> </store> 

can try

@xmlrootelement(name="store") @xmlaccessortype(xmlaccesstype.field) public class store {     // should take care of nested store elements    @xmlelement(name="store")    private list<store> stores;     @xmlelement(name="location")    private string location;     @xmlelement(name="img")    private string img;     @xmlattribute(name="id")    private string id;     @xmlattribute(name="name")    private string name;     // , include getters , setter  } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -