Parser un XML
Résolu/Fermé
powpowland
Messages postés
395
Date d'inscription
lundi 3 mars 2008
Statut
Membre
Dernière intervention
2 mars 2022
-
29 oct. 2010 à 14:36
le_joker_fou Messages postés 764 Date d'inscription mercredi 5 août 2009 Statut Membre Dernière intervention 7 août 2014 - 29 oct. 2010 à 16:58
le_joker_fou Messages postés 764 Date d'inscription mercredi 5 août 2009 Statut Membre Dernière intervention 7 août 2014 - 29 oct. 2010 à 16:58
A voir également:
- Parser un XML
- Xml viewer - Télécharger - Édition & Programmation
- Office xml handler - Télécharger - Traitement de texte
- Oxygen xml - Télécharger - Divers Web & Internet
- Driveimage xml - Télécharger - Sauvegarde
- Image xml ✓ - Forum Programmation
4 réponses
le_joker_fou
Messages postés
764
Date d'inscription
mercredi 5 août 2009
Statut
Membre
Dernière intervention
7 août 2014
239
29 oct. 2010 à 15:07
29 oct. 2010 à 15:07
Salut,
utilise la fonction : simplexml-load-file
https://www.php.net/manual/fr/function.simplexml-load-file.php
utilise la fonction : simplexml-load-file
https://www.php.net/manual/fr/function.simplexml-load-file.php
powpowland
Messages postés
395
Date d'inscription
lundi 3 mars 2008
Statut
Membre
Dernière intervention
2 mars 2022
20
29 oct. 2010 à 16:43
29 oct. 2010 à 16:43
ok merci...
par contre comment on récupère les infos après ?
en gros mon XML ressemble à ça :
et le simplexml-load-file me retourne ça :
par contre comment on récupère les infos après ?
en gros mon XML ressemble à ça :
<?xml version="1.0" encoding="ISO-8859-1"?> <rss version="2.0"> <channel> <title>test</title> <link>test.com</link> <description>testetetststsufeg ugfu</description> <item> <title>TEST 01</title> <link>http://test.com/01</link> <guid isPermaLink='false'>0</guid> <description><![CDATA[un texte test 01]]></description> </item> </channel> </rss>
et le simplexml-load-file me retourne ça :
SimpleXMLElement Object ( [@attributes] => Array ( [version] => 2.0 ) [channel] => SimpleXMLElement Object ( [title] => test [link] => test.com [description] => testetetststsufeg ugfu [item] => SimpleXMLElement Object ( [title] => TEST 01 [link] => http://test.com/01 [guid] => 0 [description] => SimpleXMLElement Object ( ) ) ) )
powpowland
Messages postés
395
Date d'inscription
lundi 3 mars 2008
Statut
Membre
Dernière intervention
2 mars 2022
20
29 oct. 2010 à 16:58
29 oct. 2010 à 16:58
c'est bon j'ai trouvé...
<?php if (file_exists('../fluxtest.xml')) { $xml = simplexml_load_file('../fluxtest.xml'); //print_r($xml); $num=0; foreach ($xml->channel->item as $value){ $num++; $title{$num} = $value->title; $link{$num} = $value->link; } for ( ; $num > 0; $num--){ echo $title{$num}."<br>".$link{$num}."<br>"; } } else { exit('Echec lors de l\'ouverture du fichier xml.'); } ?>
le_joker_fou
Messages postés
764
Date d'inscription
mercredi 5 août 2009
Statut
Membre
Dernière intervention
7 août 2014
239
29 oct. 2010 à 16:58
29 oct. 2010 à 16:58
Prenons le code suivant :
$xml = simplexml_load_file("mon flux"); $titre = $xml->channel->title; $link = $xml->channel->link; etc...