Bonjour
J'essaye de parser un XML mais je n'arrive pas à récupérer certaines informations dans mon xML:
D'abord voici à quoi ressemble mon XML:
Code XML : 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
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <product upc="00606949350727"> ... <prd_explicit_lyrics>N</prd_explicit_lyrics> <p_line>(P) 2002 Interscope Geffen (A&M) Records A Division of UMG Recordings Inc.</p_line> <c_line>(C) 2002 Geffen Records Inc.</c_line> <prd_pricing> <current_price_code>MP1</current_price_code> <current_price_effective_date>04-Jan-2007</current_price_effective_date> <current_campaign campaign_id="I702445">Universal Top 100 Artists</current_campaign> <current_campaign_end_date>31-Jan-2007</current_campaign_end_date> <current_campaign_end_price_code>TP1</current_campaign_end_price_code> <new_price_code>priceTOTO</new_price_code> <new_price_effective_date></new_price_effective_date> </prd_pricing> <prd_pricing> <current_price_code>MP2</current_price_code> <current_price_effective_date>06-Fev-2008</current_price_effective_date> <current_campaign campaign_id="I702445">Universal Top 100 Artists</current_campaign> <current_campaign_end_date>28-Fev-2008</current_campaign_end_date> <current_campaign_end_price_code>TP2</current_campaign_end_price_code> <new_price_code>priceTOTO2</new_price_code> <new_price_effective_date></new_price_effective_date> </prd_pricing> <prd_contributors> <artist_name>Nirvana</artist_name> </prd_contributors> <terms> <note></note> </terms> <prd_associated_products/> <tracks> <track isrc="USIR10211639"> <type>new</type> <volume>1</volume> <track_number>1</track_number> <track_title>You Know You're Right</track_title> <track_version_title>Album Version</track_version_title> <track_hierarchy_title></track_hierarchy_title> <asset_type>AUDIO</asset_type> <track_length>0:03:38</track_length> <track_label>Geffen</track_label> <track_explicit_lyrics></track_explicit_lyrics> <track_genre>Rock</track_genre> <track_e_marketing_tag></track_e_marketing_tag> <track_owning_label></track_owning_label> <p_line>(P) 2002 Interscope Geffen (A&M) Records A Division of UMG Recordings Inc.</p_line> <c_line></c_line> <track_pricing> <current_price_code>Unpriced</current_price_code> <current_price_effective_date>04-Jan-2007</current_price_effective_date> <new_price_code></new_price_code> <new_price_effective_date></new_price_effective_date> </track_pricing> <track_pricing> <current_price_code>TOTO Unpriced</current_price_code> <current_price_effective_date>toto 04-Jan-2007</current_price_effective_date> <new_price_code></new_price_code> <new_price_effective_date></new_price_effective_date> </track_pricing> <track_contributors> <artist_name>Nirvana</artist_name> <composer>Kurt Cobain</composer> </track_contributors> <work_level> <work_id></work_id> <work_title></work_title> <parent_work_id></parent_work_id> <parent_work_title></parent_work_title> </work_level> <terms> <singles_restriction>N</singles_restriction> <master_use> <mu_permanent>Y</mu_permanent> <mu_streaming>Y</mu_streaming> <mu_burns>Y</mu_burns> <mu_transfers>Y</mu_transfers> <mu_limited>Y</mu_limited> </master_use> <distribution_use> <channel name="Audio Download">Y</channel> <channel name="Audio Subscription">N</channel> </distribution_use> <note></note> </terms> <associated_products/> <associated_tracks/> </track> <track isrc="TOTO10211639"> <type>new</type> <volume>1</volume> <track_number>1</track_number> <track_title>You Know You're Righttoto</track_title> <track_version_title>Album Version</track_version_title> <track_hierarchy_title></track_hierarchy_title> <asset_type>AUDIO</asset_type> <track_length>0:03:38</track_length> <track_label>Geffen</track_label> <track_explicit_lyrics></track_explicit_lyrics> <track_genre>Rock</track_genre> <track_e_marketing_tag></track_e_marketing_tag> <track_owning_label></track_owning_label> <p_line>(P) 2002 Interscope Geffen (A&M) Records A Division of UMG Recordings Inc.</p_line> <c_line></c_line> <track_pricing> <current_price_code>Unpriced3</current_price_code> <current_price_effective_date>04-Jan-2007</current_price_effective_date> <new_price_code></new_price_code> <new_price_effective_date></new_price_effective_date> </track_pricing> <track_contributors> <artist_name>Nirvana</artist_name> <composer>Kurt Cobain</composer> </track_contributors> <work_level> <work_id></work_id> <work_title></work_title> <parent_work_id></parent_work_id> <parent_work_title></parent_work_title> </work_level> <terms> <singles_restriction>N</singles_restriction> <master_use> <mu_permanent>Y</mu_permanent> <mu_streaming>Y</mu_streaming> <mu_burns>Y</mu_burns> <mu_transfers>Y</mu_transfers> <mu_limited>Y</mu_limited> </master_use> <distribution_use> <channel name="Audio Download">Y</channel> <channel name="Audio Subscription">N</channel> </distribution_use> <note></note> </terms> <associated_products/> <associated_tracks/> </track> </tracks> </product>
Il y a donc une balise tracks qui contient 2 balises track. Dans ces balises tracks il peut y avoir des balises track_pricing (un nombre aléatoire pour chaque balises track).
J'aimerai pouvoir récupérer, pour charque balise track, les track_pricing qui y sont associés.
J'ai essayé de faire:
Le problème est que le tableau $tab contient tous les track_pricing du document XML sans tenir compte du track auxquels ils appartiennent.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 <?php $chemin = 'files/'.$fichier; $xml = new SimpleXMLElement(file_get_contents($chemin)); $tab = $xml->xpath('tracks/track/track_pricing'); debug($tab); ?>
Quelqu'un saurait comment faire svp?
Merci
Partager