Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > XML > SimpleXML
SimpleXML Forum d'entraide pour l'extension SimpleXML, qui permet de manipuler des documents XML en PHP (approche DOM).
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 07/01/2012, 16h18   #1
Invité de passage
 
Homme Patrick
Inscription : janvier 2012
Messages : 8
Détails du profil
Informations personnelles :
Nom : Homme Patrick
Localisation : France, Haut Rhin (Alsace)

Informations professionnelles :
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : janvier 2012
Messages : 8
Points : 0
Points : 0
Par défaut utiliser un fichier xml dans un fichier html ou php

Bonjour,

déjà je dois vous dire que je n'y connait absolument rien en fichier xml.
mais je sollicite votre savoir faire pour m'aider a mettre en place la gestion de ce fichier.

voici le fichier xml que je souhaiterai exploiter.ceci est un extrait

Code :
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalogue_informatique date="05/01/2012 08:50:21" client="s.i@neuf.fr">
<product>
<categorie><![CDATA[CONNECTIQUES]]></categorie>
<souscategorie><![CDATA[Câble / nappe]]></souscategorie>
<marque><![CDATA[BELKIN]]></marque>
<merchantid>8310</merchantid>
<modele><![CDATA[BELKIN Câble de rallonge USB - 3.1m]]></modele> 
<ref>100020</ref>
<code_ean><![CDATA[0722868246382]]></code_ean>
<ref_constructeur><![CDATA[F3U134B10]]></ref_constructeur>
<creation>03/04/2008</creation>
<descriptif_court><![CDATA[Câble de rallonge USB - USB à 4 broches, type A (M) - USB à 4 broches, type A (F) - Longueur : 3.1 m]]></descriptif_court>
<descriptif><![CDATA[
BELKIN - Câble de rallonge USB - 3.1m (F3U134B10)
 
  Type : Câble de rallonge USB
 
  Technologie : Blindé
 
  American Wire Gauge (AWG) : 20
 
  Longueur : 3 m
 
  Caractéristiques du câble : Moulé, connecteurs plaqués or
 
  Connecteur(s) : 1 x USB à 4 broches, type A - mâle
 
  Connecteur(s) (Autre côté) : 1 x USB à 4 broches, type A - femelle
 
  Conformité aux normes : USB / Hi-Speed USB
 
  Type d'emballage : Pour la vente au détail
 
  Services &amp; maintenance : Garantie limitée à vie
 
]]></descriptif>
<prix base="EUR HT">1.98</prix>
<taxes_gouv base="EUR HT">0</taxes_gouv>
<taux_tva>19.6</taux_tva>
<net_ttc base="EUR TTC">2.37</net_ttc>
<fraislivraison base="EUR TTC">7.00</fraislivraison>
<en_stock>oui</en_stock>
<stock_actuel>32</stock_actuel>
<stock_en_cours_livraison>4</stock_en_cours_livraison>
<disponibilite>05/01/2012</disponibilite>
<photo><![CDATA[http://www.rs-distribution.fr/images_produit/00008310.jpg]]></photo>
<link><![CDATA[http://www.rs-distribution.fr/produit.php?PDT_ID=8310]]></link>
<poids base="KG">1</poids>
</product>
<product>
<categorie><![CDATA[CONNECTIQUES]]></categorie>
<souscategorie><![CDATA[Câble / nappe]]></souscategorie>
<marque><![CDATA[BELKIN]]></marque>
<merchantid>8311</merchantid>
<modele><![CDATA[BELKIN Câble de rallonge USB - 1.8m]]></modele> 
<ref>100021</ref>
<code_ean><![CDATA[0722868246375]]></code_ean>
<ref_constructeur><![CDATA[F3U134B06]]></ref_constructeur>
<creation>03/04/2008</creation>
<descriptif_court><![CDATA[Câble de rallonge USB - USB à 4 broches, type A (M) - USB à 4 broches, type A (F) - Longueur : 1.8 m]]></descriptif_court>
<descriptif><![CDATA[
BELKIN - Câble de rallonge USB - 1.8m (F3U134B06)
 
  Type : Câble de rallonge USB
 
  Technologie : Blindé
 
  American Wire Gauge (AWG) : 20
 
  Longueur :*1.8 m
 
  Caractéristiques du câble : Moulé, connecteurs plaqués or
 
  Connecteur(s) : 1 x USB à 4 broches, type A - mâle
 
  Connecteur(s) (Autre côté) : 1 x USB à 4 broches, type A - femelle
 
  Conformité aux normes : USB / Hi-Speed USB
 
  Type d'emballage : Pour la vente au détail
 
  Services &amp; maintenance : Garantie limitée à vie
 
]]></descriptif>
<prix base="EUR HT">1.45</prix>
<taxes_gouv base="EUR HT">0</taxes_gouv>
<taux_tva>19.6</taux_tva>
<net_ttc base="EUR TTC">1.73</net_ttc>
<fraislivraison base="EUR TTC">7.00</fraislivraison>
<en_stock>oui</en_stock>
<stock_actuel>208</stock_actuel>
<stock_en_cours_livraison>4</stock_en_cours_livraison>
<disponibilite>05/01/2012</disponibilite>
<photo><![CDATA[http://www.rs-distribution.fr/images_produit/00008311.jpg]]></photo>
<link><![CDATA[http://www.rs-distribution.fr/produit.php?PDT_ID=8311]]></link>
<poids base="KG">0.5</poids>
</product>
<product>
<categorie><![CDATA[CONNECTIQUES]]></categorie>
<souscategorie><![CDATA[Câble / nappe]]></souscategorie>
<marque><![CDATA[CONNECTLAND]]></marque>
<merchantid>7874</merchantid>
<modele><![CDATA[Connectland Répéteur actif USB 2.0 - 5 mètres]]></modele> 
<ref>100080</ref>
<code_ean><![CDATA[3700284602316]]></code_ean>
<ref_constructeur><![CDATA[]]></ref_constructeur>
<creation>29/01/2008</creation>
<descriptif_court><![CDATA[Répéteur USB actif : prolonge le signal USB sans dégradation - Longueur 5 mètres]]></descriptif_court>
<descriptif><![CDATA[Connectland Répéteur actif USB 2.0 - 5 m (USB-REPEATER-V2-5M)
 
Conforme aux spécifications de la norme USB 2.0
 
Répéteur USB actif : prolonge le signal USB sans dégradation sur 5 mètres
 
Possibilité en ajoutant 5 répéteurs de prolonger le signal USB à 25 mètres
 
1 port USB libre requis, câble USB type A femelle – A mâle
 
Compatible Windows 98/2000/XP/MAC OS V9.0 ou supérieur
]]></descriptif>
<prix base="EUR HT">7.95</prix>
<taxes_gouv base="EUR HT">0</taxes_gouv>
<taux_tva>19.6</taux_tva>
<net_ttc base="EUR TTC">9.51</net_ttc>
<fraislivraison base="EUR TTC">7.00</fraislivraison>
<en_stock>oui</en_stock>
<stock_actuel>1</stock_actuel>
<stock_en_cours_livraison>0</stock_en_cours_livraison>
<disponibilite>05/01/2012</disponibilite>
<photo><![CDATA[http://www.rs-distribution.fr/images_produit/00007874.jpg]]></photo>
<link><![CDATA[http://www.rs-distribution.fr/produit.php?PDT_ID=7874]]></link>
<poids base="KG">1</poids>
</product>
<product>
<categorie><![CDATA[CONNECTIQUES]]></categorie>
<souscategorie><![CDATA[Câble / nappe]]></souscategorie>
<marque><![CDATA[CONNECTLAND]]></marque>
<merchantid>7876</merchantid>
<modele><![CDATA[Connectland Câble de transfert série 2x DB9F/DB25F]]></modele> 
<ref>100082</ref>
<code_ean><![CDATA[3700284608646]]></code_ean>
<ref_constructeur><![CDATA[]]></ref_constructeur>
<creation>29/01/2008</creation>
<descriptif_court><![CDATA[Câble de Transfert série 2x DB 9 F <--> 2x DB 25 F - Longueur 3 mètres]]></descriptif_court>
<descriptif><![CDATA[Connectland C-LAP4X-3S - Câble de transfert série 2x DB9F/DB25F - 3m
 
Câble de Transfert série 2x DB 9 F <--> 2x DB 25 F 
 
Longueur 3 mètres 
]]></descriptif>
<prix base="EUR HT">2.30</prix>
<taxes_gouv base="EUR HT">0</taxes_gouv>
<taux_tva>19.6</taux_tva>
<net_ttc base="EUR TTC">2.75</net_ttc>
<fraislivraison base="EUR TTC">9.90</fraislivraison>
<en_stock>oui</en_stock>
<stock_actuel>37</stock_actuel>
<stock_en_cours_livraison>0</stock_en_cours_livraison>
<disponibilite>05/01/2012</disponibilite>
<photo><![CDATA[http://www.rs-distribution.fr/images_produit/00007876.jpg]]></photo>
<link><![CDATA[http://www.rs-distribution.fr/produit.php?PDT_ID=7876]]></link>
<poids base="KG">0.3</poids>
</product>
vous remerciant par avance de votre aide
xez7082 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/01/2012, 17h10   #2
Expert Confirmé
 
Avatar de Séb.
 
Inscription : mars 2005
Messages : 2 823
Détails du profil
Informations personnelles :
Âge : 34
Localisation : France

Informations professionnelles :
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mars 2005
Messages : 2 823
Points : 3 454
Points : 3 454
Tu peux l'exploiter facilement avec SimpleXML : http://php.net/simplexml
__________________
Un problème exposé clairement est déjà à moitié résolu
Keep It Smart and Simple
Séb. est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/01/2012, 16h43   #3
Invité de passage
 
Homme Patrick
Inscription : janvier 2012
Messages : 8
Détails du profil
Informations personnelles :
Nom : Homme Patrick
Localisation : France, Haut Rhin (Alsace)

Informations professionnelles :
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : janvier 2012
Messages : 8
Points : 0
Points : 0
je ne sais pas par ou commencé, ou tout du moins comment commencé.
je suis perdu.
xez7082 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/01/2012, 19h22   #4
Expert Confirmé
 
Avatar de Séb.
 
Inscription : mars 2005
Messages : 2 823
Détails du profil
Informations personnelles :
Âge : 34
Localisation : France

Informations professionnelles :
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mars 2005
Messages : 2 823
Points : 3 454
Points : 3 454
Que veux-tu faire de ton fichier ?
__________________
Un problème exposé clairement est déjà à moitié résolu
Keep It Smart and Simple
Séb. est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2012, 07h28   #5
Invité de passage
 
Homme Patrick
Inscription : janvier 2012
Messages : 8
Détails du profil
Informations personnelles :
Nom : Homme Patrick
Localisation : France, Haut Rhin (Alsace)

Informations professionnelles :
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : janvier 2012
Messages : 8
Points : 0
Points : 0
je veus quelque chose comme ça.



merci
xez7082 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2012, 08h26   #6
Expert Confirmé
 
Avatar de Séb.
 
Inscription : mars 2005
Messages : 2 823
Détails du profil
Informations personnelles :
Âge : 34
Localisation : France

Informations professionnelles :
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mars 2005
Messages : 2 823
Points : 3 454
Points : 3 454
Faut boucler sur l'élément product, exemple :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
 
$xml = simplexml_load_file('data.xml') ;
 
echo '<table border="1">' ;
 
foreach ( $xml->product as $product ) {
    echo '<tr>' ;
    echo "<td>$product->modele</td>" ;
    // ...
    echo '</tr>' ;
}
 
echo '</table>' ;
__________________
Un problème exposé clairement est déjà à moitié résolu
Keep It Smart and Simple
Séb. est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2012, 17h15   #7
Invité de passage
 
Homme Patrick
Inscription : janvier 2012
Messages : 8
Détails du profil
Informations personnelles :
Nom : Homme Patrick
Localisation : France, Haut Rhin (Alsace)

Informations professionnelles :
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : janvier 2012
Messages : 8
Points : 0
Points : 0
j'ai écrit une dtd, je ne sais pas si c'est bon.
mais j'ai au moins essayé.

Code :
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
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT taxes_gouv (#PCDATA)>
<!ATTLIST taxes_gouv
	base CDATA #FIXED "EUR HT"
>
<!ELEMENT taux_tva (#PCDATA)>
<!ELEMENT stock_en_cours_livraison (#PCDATA)>
<!ELEMENT stock_actuel (#PCDATA)>
<!ELEMENT souscategorie (#PCDATA)>
<!ELEMENT ref_constructeur (#PCDATA)>
<!ELEMENT ref (#PCDATA)>
<!ELEMENT product ((categorie, souscategorie, marque, merchantid, modele, ref, code_ean, ref_constructeur, creation, descriptif_court, descriptif, prix, taxes_gouv, taux_tva, net_ttc, fraislivraison, en_stock, stock_actuel, stock_en_cours_livraison, disponibilite, photo, link, poids))>
<!ELEMENT prix (#PCDATA)>
<!ATTLIST prix
	base CDATA #FIXED "EUR HT"
>
<!ELEMENT poids (#PCDATA)>
<!ATTLIST poids
	base CDATA #FIXED "KG"
>
<!ELEMENT photo (#PCDATA)>
<!ELEMENT net_ttc (#PCDATA)>
<!ATTLIST net_ttc
	base CDATA #FIXED "EUR TTC"
>
<!ELEMENT modele (#PCDATA)>
<!ELEMENT merchantid (#PCDATA)>
<!ELEMENT marque (#PCDATA)>
<!ELEMENT link (#PCDATA)>
<!ELEMENT fraislivraison (#PCDATA)>
<!ATTLIST fraislivraison
	base CDATA #FIXED "EUR TTC"
>
<!ELEMENT en_stock (#PCDATA)>
<!ELEMENT disponibilite (#PCDATA)>
<!ELEMENT descriptif_court (#PCDATA)>
<!ELEMENT descriptif (#PCDATA)>
<!ELEMENT creation (#PCDATA)>
<!ELEMENT code_ean (#PCDATA)>
<!ELEMENT categorie (#PCDATA)>
<!ELEMENT catalogue_informatique ((product+))>
<!ATTLIST catalogue_informatique
	client CDATA #FIXED "s.i@neuf.fr"
	date CDATA #FIXED "05/01/2012 08:50:21"
>
xez7082 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2012, 17h24   #8
Expert Confirmé
 
Avatar de Séb.
 
Inscription : mars 2005
Messages : 2 823
Détails du profil
Informations personnelles :
Âge : 34
Localisation : France

Informations professionnelles :
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mars 2005
Messages : 2 823
Points : 3 454
Points : 3 454
Euh, je ne vois pas le rapport avec le sujet :\
__________________
Un problème exposé clairement est déjà à moitié résolu
Keep It Smart and Simple
Séb. est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/01/2012, 07h55   #9
Invité de passage
 
Homme Patrick
Inscription : janvier 2012
Messages : 8
Détails du profil
Informations personnelles :
Nom : Homme Patrick
Localisation : France, Haut Rhin (Alsace)

Informations professionnelles :
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : janvier 2012
Messages : 8
Points : 0
Points : 0
on m'a dit qu'il faux trois type de fichier pour afficher du xml
le fichier xml
un fichier dtd
un fichier xsl

donc cette ordre, donc je me suis atteler au dtd.
si il existe une solution plus simple je suis preneur.
je me suis apparemment planter.

si je comprend bien votre fichier suffit.
xez7082 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/01/2012, 08h52   #10
Expert Confirmé
 
Avatar de Séb.
 
Inscription : mars 2005
Messages : 2 823
Détails du profil
Informations personnelles :
Âge : 34
Localisation : France

Informations professionnelles :
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mars 2005
Messages : 2 823
Points : 3 454
Points : 3 454
Citation:
Envoyé par xez7082 Voir le message
on m'a dit qu'il faux trois type de fichier pour afficher du xml
le fichier xml
un fichier dtd
Le DTD ne sert qu'à nous informer de la structure d'un XML et à le valider.

Citation:
un fichier xsl
Cela sert à transformer un XML, le DTD n'est pas nécessaire.

Citation:
si je comprend bien votre fichier suffit.
Oui.
__________________
Un problème exposé clairement est déjà à moitié résolu
Keep It Smart and Simple
Séb. est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/01/2012, 11h34   #11
Invité de passage
 
Homme Patrick
Inscription : janvier 2012
Messages : 8
Détails du profil
Informations personnelles :
Nom : Homme Patrick
Localisation : France, Haut Rhin (Alsace)

Informations professionnelles :
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : janvier 2012
Messages : 8
Points : 0
Points : 0
j’étais en déplacement bon maintenant mon problème ce sont les images, je n'arrive pas a les afficher.

y a t-il un code spécial sachant que ces images sont stocké chez mon fournisseur.
je dispose que de mon fichier xml pour tout gérer.
<photo><![CDATA[http://www.rs-distribution.fr/images_produit/00008310.jpg]]></photo>

pouvez-vous m'aider svp.

avec mes remerciements
xez7082 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/01/2012, 13h23   #12
Expert Confirmé
 
Avatar de Séb.
 
Inscription : mars 2005
Messages : 2 823
Détails du profil
Informations personnelles :
Âge : 34
Localisation : France

Informations professionnelles :
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mars 2005
Messages : 2 823
Points : 3 454
Points : 3 454
Il faut extraire l'URL de :

Code :
<photo><![CDATA[http://www.rs-distribution.fr/images_produit/00008310.jpg]]></photo>
Et faire :

__________________
Un problème exposé clairement est déjà à moitié résolu
Keep It Smart and Simple
Séb. est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 23/01/2012, 18h35   #13
Invité de passage
 
Homme Patrick
Inscription : janvier 2012
Messages : 8
Détails du profil
Informations personnelles :
Nom : Homme Patrick
Localisation : France, Haut Rhin (Alsace)

Informations professionnelles :
Secteur : High Tech - Matériel informatique

Informations forums :
Inscription : janvier 2012
Messages : 8
Points : 0
Points : 0
ok super sa fonctionne.

mais maintenant j'aimerais faire un moteur de trie comme plus haut.

pouvoir choisir une categorie, une fois que la categorie est choisit pouvoir choisir une marque et après affiner la recherche en choisissant le prix la ref etc..

est-ce faisable et si oui peus-tu m'aider ?

merci
xez7082 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 08h48.


 
 
 
 
Partenaires

Hébergement Web