y question is simple but I didn´t find anyone else with the same problem. I am trying to use JAXB to create a XML,so I have the class:
@XmlRootElement
public class Container{
private String name;
private String value;
public Container(String name, String value){
this.name = name;
this.value = value;
}
}
Using the marshal :
public class Demo {
public static void main(String[] args) throws Exception {
JAXBContext jc = JAXBContext.newInstance(Container.class);
Container container = new Container("potatoes","5");
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(container, System.out);
}
}
The output that I receive is:
<Container>
<name>potatoes</name>
<value>5</value>
</Container>
is there any way of the output be like:
<Container>
<potatoes>5</potatoes>
</Container>
Using the JAXB?