tags:

views:

64

answers:

3

Given the following XML Snippet

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

What is the XPath query to return all Events created today of type download?

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

Since I assume that this is a follow-up to your previous question, you might want to use this snippet instead of SelectSingleNode to get all events in a file (if there can be multiple):

foreach (XPathNavigator node in doc.CreateNavigator().Select(expression)) {
 // matching node found in document; will process all matching nodes
}
Lucero
+1  A: 
//Events/Event[contains(DateTime,'22.09.2009') and EventType='Download']
aJ
+1  A: 
/Events/Event[substring(DateTime, 0, 10)='22.09.2009' and EventType='Download']
Björn
Sorry but I don't see how a regular expression would help in finding today's date?
Lucero
Actually, neither do I...
Björn