Bonjour à tous,
Je tiens à vous dire que je suis un novice en xml donc excuser mes questions et autres incompréhensions
Je souhaite récupérer les données d'un xml pour les insérer dans une base de données mysql par la suite.
Mon problème c'est que je n'arrive pas récupérer une partie des données de mon xml que voici
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
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 <?xml version='1.0' encoding='windows-1252'?> <annonces> <annonce> <client>OPTIMHOME</client> <reference>123456</reference> <titre>APPARTEMENT A ARGENTEUIL</titre> <texte>(95) ARGENTEUIL F4 LUMINEUX (BAIES VITREES) ET FONCTIONNEL, COMPOSE DE : ENTREE, SEJOUR, CUIS EQUIP INDEPENDANTE, 3 CHAMBRES, 2 DRESSING, PLACE DE PARKING PRIVEE, GARDIEN, INTERPHONE. ECOLES, GARE ET COMMERCES SUR PLACE. A DECOUVRIR : CONTACTER LYES AGENT MANDATAIRE 95 AU</texte> <date_saisie>09/11/2008</date_saisie> <photos> <photo>http://www.optimhome.com/images/upload/biens/A-abdly-1010365413-P.jpg</photo> <photo>http://www.optimhome.com/images/upload/biens/A-abdly-1010365413-P.jpg</photo> <photo>http://www.optimhome.com/images/upload/biens/A-abdly-1010365413-P.jpg</photo> <photo>http://www.optimhome.com/images/upload/biens/A-abdly-1010365413-P.jpg</photo> <photo>http://www.optimhome.com/images/upload/biens/A-abdly-1010365413-P.jpg</photo> <photo>http://www.optimhome.com/images/upload/biens/A-abdly-1010365413-P.jpg</photo> </photos> <agence> <telAgence>06 34 00 55 23</telAgence> <emailAgence>test@optimhome.com</emailAgence> <nomAgence>Agent mandataire Optimhome Test</nomAgence> </agence> <bien> <code_type>APPARTEMENT</code_type> <code_postal>95100</code_postal> <ville>ARGENTEUIL</ville> <code_insee approximatif='false'></code_insee> <surface>130</surface> <nb_pieces>4</nb_pieces> <prix>235000</prix> </bien> <prestation> <type>VENTE</type> </prestation> </annonce> </annonces>
voici mon code php pour récupérer les données
Je ne récupère plus les données après <date_saisie></date_saisie>.
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
18
19
20
21
22
23
24
25
26 <?php $optimhome_xml = simplexml_load_file('exemple.xml'); foreach ($optimhome_xml ->annonce as $annonce) { print "Client: {$annonce->client} <br />\n"; print "Référence: {$annonce->reference} <br />\n"; print "Titre: {$annonce->titre} <br />\n"; print "Texte: {$annonce->texte} <br />\n"; print "Date: {$annonce->date_saisie} <br />\n"; print "Photos: {$annonce->photos} <br />\n"; print "Photo Path: {$photos->photo} <br />\n"; print "Agence: {$annonce->agence} <br />\n"; print "Tel Agence: {$annonce->telAgence} <br />\n"; print "Email Agence: {$annonce->emailAgence} <br />\n"; print "Nom Agence: {$annonce->nomAgence} <br />\n"; print "Bien: {$annonce->bien} <br />\n"; print "Code Type: {$annonce->code_type} <br />\n"; print "Code Postal: {$annonce->code_postal} <br />\n"; print "Ville: {$annonce->ville} <br />\n"; print "Surface: {$annonce->surface} <br />\n"; print "Nombre de pièces: {$annonce->nb_pieces} <br />\n"; print "Prix: {$annonce->prix} <br />\n"; print "Prestation: {$annonce->prestation} <br />\n"; print "Type: {$annonce->type} <br />\n"; } ?>
Il faudrait que je passe plusieurs paramètres dans le foreach je pense j'ai cherché la syntaxe que je n'ai pas trouvé sans mettre plusieurs paramètres je pensais queaurait pu me donner accès aux données <photo></photo> mais sans succès.
Code : Sélectionner tout - Visualiser dans une fenêtre à part foreach ($optimhome_xml ->photos as $photos)
Tous vos conseils sont les bienvenus, je vous remercie d'avance.
Partager