我有一个xml数据源,它返回一个像这样的xml:
<ArrayOfAttendanceStudentExchangeModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<AttendanceStudentExchangeModel>
<Counter>1</Counter>
<FatherLastName>Roque</FatherLastName>
<MotherLastName>Parisaca</MotherLastName>
<Names>Sergio Gustavo</Names>
<Attendances>
<string>P</string>
<string>F</string>
<string>F</string>
<string>P</string>
<string>P</string>
<string>P</string>
<string>P</string>
<string>P</string>
</Attendances>
</AttendanceStudentExchangeModel>
</ArrayOfAttendanceStudentExchangeModel>
web api方法将某种类型的Collection作为XMl返回。
public class AttendanceStudentExchangeModel
{
public int Counter { get; set; }
public string FatherLastName { get; set; }
public string MotherLastName { get; set; }
public string Names { get; set; }
public string[] Attendances { get; set; }
}
[HttpGet]
public HttpResponseMessage GetAttendanceSheet(string codigoDocente, int codigoHorario, int periodCode)
{
{
AttendanceSheetService attendanceSheetBuilder = new AttendanceSheetService();
var attendanceSheetResult = attendanceSheetBuilder.GetAttendanceSheetCollection(codigoDocente, codigoHorario, periodCode);
var content = new ObjectContent<List<AttendanceStudentExchangeModel>>(attendanceSheetResult, Configuration.Formatters.XmlFormatter);
return new HttpResponseMessage()
{
Content = content
};
}
}
数据集中的查询:
<Query>
<ElementPath>
ArrayOfAttendanceStudentExchangeModel {} /AttendanceStudentExchangeModel
</ElementPath>
</Query>
我手动定义了字段:
结果:
出勤人数(Asistencias)可能因查询而异。
我怎样才能做到这一点?