XPath Query à correspondre en fonction des combinaisons d'éléments enfants

StackOverflow https://stackoverflow.com/questions/1460028

  •  12-09-2019
  •  | 
  •  

Question

Compte tenu de l'extrait XML suivant

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

Quelle est la requête XPath pour retourner tous les événements créés aujourd'hui de téléchargement de type?

Était-ce utile?

La solution

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

Puisque je suppose qu'il s'agit d'un suivi de votre question précédente, vous voudrez peut-être utiliser cet extrait au lieu de sélectionner leLenode pour obtenir tous les événements dans un fichier (s'il peut y avoir plusieurs):

foreach (XPathNavigator node in doc.CreateNavigator().Select(expression)) {
    // matching node found in document; will process all matching nodes
}

Autres conseils

//Events/Event[contains(DateTime,'22.09.2009') and EventType='Download']
/Events/Event[substring(DateTime, 0, 10)='22.09.2009' and EventType='Download']
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top