Linq to XML 获取更新的日期元素
<Itinerary Id="34" Code="2010STAN" Modified="2010-09-07 16:58:35">
<Itinerary Id="34" Code="2010STAN" Modified="2010-11-12 15:53:13">
<Itinerary Id="34" Code="2010STAN" Modified="2011-11-12 15:53:13">
我得到了那个 XML。要求是:
我想从 Linq to XML 查询获取更新的日期/大日期。例如我想获得最后一个节点。“2011-11-12 15:53:13”
请帮忙!
<Itinerary Id="34" Code="2010STAN" Modified="2010-09-07 16:58:35">
<Itinerary Id="34" Code="2010STAN" Modified="2010-11-12 15:53:13">
<Itinerary Id="34" Code="2010STAN" Modified="2011-11-12 15:53:13">
I get that XML. and requirement is:
I want to get newer date / Large Date from Linq to XML query. for instance i want to get last node."2011-11-12 15:53:13"
PLEASE HELP!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是在寻找整个元素,还是只是日期本身?对于日期,很简单:
要获取包含最新日期的元素,您必须对它们进行排序并获取第一个元素,例如
,或者使用类似
MaxBy
来自 MoreLINQ:Are you looking for the whole element, or just the date itself? For the date, it's easy:
To get the element containing the latest date, you'd either have to sort them and take the first element, e.g.
or use something like
MaxBy
from MoreLINQ: