题
给定以下XML摘要
<Events>
<Event>
<DateTime>22.09.2009 11:27:18</DateTime>
<EventType>Download</EventType>
</Event>
返回今天创建的所有类型下载的所有事件的XPath查询是什么?
解决方案
/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
}
其他提示
//Events/Event[contains(DateTime,'22.09.2009') and EventType='Download']
/Events/Event[substring(DateTime, 0, 10)='22.09.2009' and EventType='Download']
不隶属于 StackOverflow