将嵌套的XML转换为Java对象的正确方法

我正在尝试将以下XML字符串(1)转换为Java对象。

I am trying to follow this tutorial : https://www.javatpoint.com/jaxb-unmarshalling-example but not able to do it correctly. I have 3 class files : AccountObject (2), checkingAccts (3), loanAccts (4).

需要注意的一点是,所有值都可以为空/空,即支票帐户列表,贷款帐户列表和状态为空。

将XML转换为对象的可接受方法是什么?

(1)

<AccountObject xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <categories
        xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <a:string>category</a:string>
        <a:string>category</a:string>
    </categories>
    <checkingAccts>
        <CheckingAccts>
            <acctNbr>1111</acctNbr>
            <acctStatus>0</acctStatus>
            <availBalance>14299.49</availBalance>
            <balance>14294.49</balance>
            <dateOpened>2017-09-07</dateOpened>
            <type>4020</type>
        </CheckingAccts>
        <CheckingAccts>
            <acctNbr>2222</acctNbr>
            <acctStatus>0</acctStatus>
            <availBalance>470.72</availBalance>
            <balance>465.72</balance>
            <dateOpened>2017-09-18</dateOpened>
            <type>4020</type>
        </CheckingAccts>
        <CheckingAccts>
            <acctNbr>4444</acctNbr>
            <acctStatus>0</acctStatus>
            <availBalance>5.00</availBalance>
            <balance>0.00</balance>
            <dateOpened>2018-04-26</dateOpened>
            <type>4200</type>
        </CheckingAccts>
    </checkingAccts>
    <loanAccts>
        <LoanAccts>
            <acctNbr>1111</acctNbr>
            <acctStatus>0</acctStatus>
            <availBalance>25000.00</availBalance>
            <balance>1100.03</balance>
            <dateOpened>2017-10-13</dateOpened>
            <type>6190</type>
        </LoanAccts>
        <LoanAccts>
            <acctNbr>2222</acctNbr>
            <acctStatus>0</acctStatus>
            <availBalance>87777.00</availBalance>
            <balance>0.00</balance>
            <dateOpened>2018-04-26</dateOpened>
            <type>6160</type>
        </LoanAccts>
    </loanAccts>
    <statusMessage>THIS IS A TEST MESSAGE</statusMessage>
</AccountObject>

(2)

import java.util.List;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "AccountObject")
public class AccountObject {

    private String statusMessage;
    private List<CheckingAccts> checkingAccounts;
    private List<LoanAccts> loanAccounts;   


    public List<LoanAccts> getLoanAccounts() {
        return loanAccounts;
    }

    public void setLoaanAccounts(List<LoanAccts> loaanAccounts) {
        this.loanAccounts = loaanAccounts;
    }

    public String getStatusMessage() {
        return statusMessage;
    }

    public void setStatusMessage(String statusMessage) {
        this.statusMessage = statusMessage;
    }


    public List<CheckingAccts> getCheckingAccounts() {
        return checkingAccounts;
    }

    public void setCheckingAccounts(List<CheckingAccts> checkingAccounts) {
        this.checkingAccounts = checkingAccounts;
    }

}

(3)

public class CheckingAccts {

    protected String acctNbr;
    protected String acctStatus;
    protected String availBalance;
    protected String balance;
    protected String dateOpened;
    protected String type;

    public String getAcctNbr() {
        return acctNbr;
    }

    public void setAcctNbr(String acctNbr) {
        this.acctNbr = acctNbr;
    }

    public String getDateOpened() {
        return dateOpened;
    }

    public void setDateOpened(String dateOpened) {
        this.dateOpened = dateOpened;
    }

    public String getAcctStatus() {
        return acctStatus;
    }

    public void setAcctStatus(String acctStatus) {
        this.acctStatus = acctStatus;
    }

    public String getBalance() {
        return balance;
    }

    public void setBalance(String balance) {
        this.balance = balance;
    }

    public String getAvailBalance() {
        return availBalance;
    }

    public void setAvailBalance(String availBalance) {
        this.availBalance = availBalance;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}

(4)

public class LoanAccts {

    protected String acctNbr;
    protected String acctStatus;
    protected String availBalance;
    protected String balance;
    protected String dateOpened;
    protected String type;


    public String getAcctNbr() {
        return acctNbr;
    }

    public void setAcctNbr(String acctNbr) {
        this.acctNbr = acctNbr;
    }

    public String getAcctStatus() {
        return acctStatus;
    }

    public void setAcctStatus(String acctStatus) {
        this.acctStatus = acctStatus;
    }

    public String getBalance() {
        return balance;
    }

    public void setBalance(String balance) {
        this.balance = balance;
    }

    public String getAvailBalance() {
        return availBalance;
    }

    public void setAvailBalance(String availBalance) {
        this.availBalance = availBalance;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getDateOpened() {
        return dateOpened;
    }

    public void setDateOpened(String dateOpened) {
        this.dateOpened = dateOpened;
    }

}