Web 服务返回如下所示的文档:
<CarrierService.GetAlerts>
<ResponseDO>
<status>APPROVED</status>
<action>OK</action>
<code>SFW00542</code>
<displayMsg/>
<techMsg/>
</ResponseDO>
<AlertList count="1">
<AlertItem>
<docketNumber>MC758</docketNumber>
<dotNumber>17952</dotNumber>
<Change>
<Field>rating</Field>
<From>Conditional</From>
<To>Satisfactory</To>
</Change>
<Change>
<Field>rateDate</Field>
<From>2010-08-31</From>
<To>2010-12-20</To>
</Change>
</AlertItem>
</AlertList>
</CarrierService.GetAlerts>
我正在使用 XmlSerializer,这就是我的映射类的外观:
[XmlRoot("CarrierService.GetAlerts")]
public class GetAlertsResponse
{
[XmlElement(ElementName = "ResponseDO")]
public ResponseDo ResponseDo { get; set; }
[XmlArray(ElementName = "AlertList")]
public List<AlertItem> AlertList { get; set; }
}
public class AlertItem
{
[XmlElement(ElementName = "docketNumber")]
public string DocketNumber { get; set; }
[XmlElement(ElementName = "dotNumber")]
public string DOTNumber { get; set; }
}
我对 AlertItem.Change 有疑问。它在 AlertItem 中重复,并且没有包含在“ChangeList”中。
我该如何反序列化这些项目?