How can I generate the following XML using JAXB?
<sport type="" gender=""> sport description </sport>
Annotate type and gender properties with @XmlAttribute and the description property with @XmlValue:
@XmlAttribute
@XmlValue
package org.example.sport; import javax.xml.bind.annotation.*; @XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement public class Sport { @XmlAttribute protected String type; @XmlAttribute protected String gender; @XmlValue; protected String description; }
For More Information
1.4m articles
1.4m replys
5 comments
56.9k users