【发布时间】:2011-12-28 19:45:10
【问题描述】:
下面是我的xml...
我想要做的是使用 XPATH 和计数表达式。我想要计算 xml 中的日期何时与今天的日期匹配。因此,例如今天的日期是“2011-05-05”.. 任何与此日期匹配的消息都有一个计数并返回一个整数。所以答案是 NumberofTodaysMessages = 2。
<Response>
<run_id>1</run_id>
<message>
<timestamp>2011-05-05T10:50:00.46875+00:00</timestamp>
<event_type>Information</event_type>
<operation>LoadProjects</operation>
<error_code />
<details>LoadProjects request detected</details>
</message>
<message>
<timestamp>2011-05-05T10:50:02.296875+00:00</timestamp>
<event_type>Error</event_type>
<operation>Processor.InitaliseDCFiles</operation>
<error_code />
<details>some error details</details>
</message>
<message>
<timestamp>2011-11-10T10:50:02.296875+00:00</timestamp>
<event_type>Debug</event_type>
<operation>Processor.InitaliseDCFiles</operation>
<error_code />
<details>some details</details>
</message>
<Response>
我将如何在 XPATH 中解决这个问题??
count(/Response/message/Timestamp[@DateTime.Now()])
【问题讨论】:
标签: c# xml datetime xpath count