两种方法:
1 <node att="att">text</node>
1 @XStreamAlias("node") 2 @XStreamConverter(value=ToAttributedValueConverter.class, strings={"text"}) 3 public class Node { 4 private String att; 5 private String text; 6 }
1 @XStreamAlias("node") 2 public class Node { 3 @XStreamAsAttribute 4 private String att; 5 private String text; 6 }
第一种适合属性比节点多的情况,第二种反之;