2
我有這樣一個類:如何用Xstream省略標籤?
public class revision{
long number;
String comment;
... getters and setters
}
,我想XStream的結果給是這樣的:
<revision comment="value of comment">
121556
</revision>
然而,由於數字是場它迫使我把它寫在<number>
標籤。
我用這個來創建XML:
XStream xstream = new XStream(new DomDriver("UTF-8"));
xstream.useAttributeFor(Revision.class, "comment");
是有可能不顯示的標籤?