I want to create xml from my object, but instead of xml nodes I’d like to create attribute i.e.
@XmlRootElement
class MyObject{
private String name;
private String age;
...getters/setters...
}
And I want my object to create this xml :
<MyObject name="something">
<age></age>
</MyObject>
How can I do this?
You can use the
@XmlAttributeannotation to map to an XML attribute.