我有从数据库数据生成xml的代码。将字符串转换为正确的日期字符串
这里是它
public HttpResponseMessage Index(DateTime today)
{
var timeTables = db.TimeTables
.Where(c=> c.Today == today)
.Select(c => new
{
c.INN,
c.StartDay,
c.StartPause,
c.EndPause,
c.EndDay
}).AsEnumerable();
var xdoc = new XDocument(
new XElement("data",
timeTables.Select(w =>
new XElement("worker",
new XAttribute("id", w.INN),
new XElement("start", w.StartDay),
new XElement("pause", w.StartPause),
new XElement("continue", w.EndPause),
new XElement("end", w.EndDay)
)
)
)
);
return new HttpResponseMessage() { Content = new StringContent(xdoc.ToString(), Encoding.UTF8, "application/xml") };
}
数据是从移动应用请求花费。移动应用程序发送c.StartDay例如像这样17-8-2017T10:8:3
。在xml我需要显示它这样的yyyy-MM-ddTHH:mm:ss
我怎么能这样做的XML生成?
但'c.StartDay'还可以' 17-12-2017T10:45:55'?=! –
是的。你是对的@ MongZhu –
它必须记录在'yyyy-MM-ddTHH:mm:ss' @MongZhu –