0

给定以下 XML 片段

 <Events>
    <Event>
     <DateTime>22.09.2009 11:27:18</DateTime>
     <EventType>Download</EventType>
 </Event>

返回今天创建的所有下载类型事件的 XPath 查询是什么?

4

3 回答 3

3
/Events/Event[starts-with(DateTime, '22.09.2009') and EventType='Download']

由于我假设这是您之前问题的后续,您可能希望使用此代码段而不是 SelectSingleNode 来获取文件中的所有事件(如果可以有多个):

foreach (XPathNavigator node in doc.CreateNavigator().Select(expression)) {
    // matching node found in document; will process all matching nodes
}
于 2009-09-22T13:18:20.340 回答
1
//Events/Event[contains(DateTime,'22.09.2009') and EventType='Download']
于 2009-09-22T13:19:30.323 回答
1
/Events/Event[substring(DateTime, 0, 10)='22.09.2009' and EventType='Download']
于 2009-09-22T13:21:18.573 回答