Bonjour,
Je ne trouve pas la bonne méthode pour arriver à filtrer un fichier XML proprement.
J'ai un fichier avec 4 niveaux : echange = root, puis des noeuds institutions qui contiennent des noeuds structures qui contiennent des noeuds prestations.
Le but est de produire un nouveau xml contenant que l’arborescence qui correspond à flag='oui'
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 <?xml version="1.0" encoding="ISO-8859-1"?> <echange echange_date="2014-11-03"> <institution id_tiers="408209644" > <structure id_tiers="408209644" id_structure="299734199" > <prestation id_tiers="408209644" id_structure="299734199" id_prestation="303341377" flag="oui"/> </structure> </institution> <institution id_tiers="408210515" > <structure id_tiers="408210515" id_structure="21560434"> <prestation id_tiers="408210515" id_structure="21560434" id_prestation="1254115" flag="oui"/> <prestation id_tiers="408210515" id_structure="21560434" id_prestation="21560981" flag="non"/> <prestation id_tiers="408210515" id_structure="21560434" id_prestation="29041603" flag="non"/> </structure> </institution> </echange>
comme ci-dessous
J'ai utilisé le code ci-après pour "remonter" sur le grand-père, mais du coup j'ai tout les enfants et petit-enfants du noeud, donc mon filtre ne sert plus à rien.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 <?xml version="1.0" encoding="ISO-8859-1"?> <echange echange_date="2014-11-03"> <institution id_tiers="408209644" > <structure id_tiers="408209644" id_structure="299734199" > <prestation id_tiers="408209644" id_structure="299734199" id_prestation="303341377" flag="oui"/> </structure> </institution> <institution id_tiers="408210515" > <structure id_tiers="408210515" id_structure="21560434"> <prestation id_tiers="408210515" id_structure="21560434" id_prestation="1254115" flag="oui"/> </structure> </institution> </echange>
Code : Sélectionner tout - Visualiser dans une fenêtre à part <xsl:copy-of select="../parent::node()|@*"/>
Partager