I want to generate following XML using JAXB
<Data>
<text lang="en"/>
<text align="center"/>
.
.
.
<text>TICKET</text>
<feed unit="12"/>
<text align="left"/>
<text>Order 1234</text>
<text width="1" height="1"/>
.
.
.
<text>TOTAL</text>
<feed unit="12"/>
<feed line="3"/>
.
.
.
<Data>
My problem here is that I don't know how many <text>
& <feed>
will be there at what order.
Is it possible to create such XML using JAXB?
I am using following class but I can't get the <text>
after <feed>
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement(name = "Data")
public class Data {
private List<Text> text;
private List<Feed> feed;
@XmlElement(name = "text")
public List<Text> getText() {
return text;
}
public void setText(List<Text> text) {
this.text = text;
}
@XmlElement(name = "feed")
public List<Feed> getFeed() {
return feed;
}
public void setFeed(List<Feed> feed) {
this.feed = feed;
}
}
几天后,我一直在寻找解决方案,但最终还是使用了Freemarker
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.