I've been trying to find a similar answered question but I haven't had any luck.
I basically need to read some data off a text file and then marshal it to XML. Normal formatting though, creates
<title></title>
fields etc. while what I want is every field to have this format:
<field name="title"></field>.
"title" here is just a placeholder, what I want is for the name attribute to have the variable name which it is bound, so
<title>
becomes
<field name="title">
,
<author>
becomes
<field name="author"> etc.
I'm guessing it has something to do with the annotations that I'm not getting.
My document class has a simple structure, like
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Document
{
private Integer id;
private String content;
private String title;
private String author;
private String b;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…