Create dynamic Tags in XML using JAXB

pinsurancejbku

New Member
I have two classes as follow : \[code\]`@XmlRootElement public class MyTO {private int type;private String data;@XmlElement(name = "type")public int getType() { return type;}public void setType(int type) { this.type = type;}@XmlElement(name = "data")public String getData() { return data;}public void setData(String data) { this.data = http://stackoverflow.com/questions/10816519/data;}\[/code\]}and\[code\]@XmlRootElement(name = "parentTo") public class ParentTO {private MyTO to;/** * @return the to */public MyTO getTo() { return to;}/** * @param to * the to to set */public void setTo(MyTO to) { this.to = to;}\[/code\]}I want to have a XML like this\[code\]<parentTo><kind1> <data>data2</data> <type>1</type></kind1><kind2> <data>data2</data> <type>2</type></kind2>\[/code\]Basically I want to generate tags and based on the value of tag .if it is 1 then as parent of that node and if the value of is 2.Is it possible to do that using JAXB?
 
Back
Top