Modifier un peu le code de print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output) pour afficher le contenu des attributs.
Et avec ton fichier :
[alex@zzz ~/xpath]$ ./xpath1 test.xml "//package[contains(./depends/text(),'libxml2')]/@name"
Result (2 nodes):
= attribute "name"
value="fpack2"
D'ailleurs attention aux effet parasite : si tu cherche le package "base" alors qu'un package s'appelle "xmlbase" -> tu match alors que tu ne devrais pas.
[^] # testé et
Posté par _alex . En réponse au message XPath : comment formuler cette requête ?. Évalué à 2.
J'ai pris cet exemple de la doc : http://www.xmlsoft.org/examples/index.html#xpath1.c(...)
Modifier un peu le code de print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output) pour afficher le contenu des attributs.
Et avec ton fichier :
[alex@zzz ~/xpath]$ ./xpath1 test.xml "//package[contains(./depends/text(),'libxml2')]/@name"
Result (2 nodes):
= attribute "name"
value="fpack2"
[alex@zzz ~/xpath]$ ./xpath1 test.xml "//package[contains(./depends/text(),'base')]/@name"
Result (3 nodes):
= attribute "name"
value="hdparm"
= attribute "name"
value="fpack2"
D'ailleurs attention aux effet parasite : si tu cherche le package "base" alors qu'un package s'appelle "xmlbase" -> tu match alors que tu ne devrais pas.
Code en peluche :