我有一个包含此内容的xml文件。每笔交易以trans_开头,以交易号
结束<trans_1>
<date>2013/10/10</date>
<code>109129</code>
<amount>+000000024000000</amount>
<balance>+000000024000000</balance>
</trans_1>
<trans_2>
<date>2013/10/10</date>
<code>109149</code>
<amount>+000000025000000</amount>
<balance>+000000049000000</balance>
</trans_2>
<trans_3>
<date>2013/10/10</date>
<code>109161</code>
<amount>+000000005000000</amount>
<balance>+000000054000000</balance>
</trans_3>
我想将此数组映射到以下对象列表。
class Transaction{
string date;
string code;
string amount;
string balance;
/**** getter and setter ***/
}
答案 0 :(得分:0)
我找到了@XmlElements
@XmlAccessorType(XmlAccessType.FIELD)
public class DepositLast3CycleResponse extends BaseResponseBean {
@XmlElements(
{
@XmlElement(name = "trans_1"),
@XmlElement(name = "trans_2"),
@XmlElement(name = "trans_3")
}
)
private List<TransactionInfo> transactions;
/****** getters and setters ****/
}