我不知道如何將一些XML表示爲C#類。有沒有人有任何建議,如何正確地映射這個XML?這是我下面嘗試:映射對類的xml響應?
<authenticationResponse>
<Accounts>
<AccountId>1</AccountId>
<AccountId>5</AccountId>
</Accounts>
</authenticationResponse>
public class authenticationResponse
{
[XmlElement("Accounts")]
[DataMember]
public List<Account> Accounts { get; set; }
}
public class Account
{
public long id { get; set; }
}
那麼,你有什麼問題? –
我正在使用Microsoft Webapi從REST端點讀取數據。返回的xml正確地填充了accountids,但List中的對象是null。 – user486480
請顯示完整的XML。 –