Suppression noeud XML en PHP
Résolu
Apaachee
Messages postés
261
Statut
Membre
-
Apaachee Messages postés 261 Statut Membre -
Apaachee Messages postés 261 Statut Membre -
Bonjour,
VOici mon fichier xml :
Et voici mon code php :
Le $a prend bien la bonne valeur à supprimer mais rien ne se passe avec la fonction unset... Que faire...?
VOici mon fichier xml :
<Collection> <BD> <titre>Tintin au tibet</titre> <dessinateur>herge</dessinateur> <scenariste>herge</scenariste> <editeur>nouvelediteur</editeur> <serie>Tintin</serie> <annee>1782</annee> </BD> <BD> ...
Et voici mon code php :
$collection = simplexml_load_file("../Information/Collection/".$login.".xml ");
$i=0;
$a = -1;
foreach($collection->children() as $bd){
if($collection->BD[$i]->titre == $_GET["titre"] && $collection->BD[$i]->annee == $_GET["annee"])
$a = $i;
$i++;
}
if($a >= -1)
unset($collection->BD[$a]);
Le $a prend bien la bonne valeur à supprimer mais rien ne se passe avec la fonction unset... Que faire...?
A voir également:
- Suppression noeud XML en PHP
- Forcer suppression fichier - Guide
- Xml download - Télécharger - Édition & Programmation
- Easy php - Télécharger - Divers Web & Internet
- Office xml handler - Télécharger - Traitement de texte
- Suppression compte gmail - Guide
1 réponse
$collection = simplexml_load_file("../Information/Collection/".$login.".xml ");
$i=0;
$a = -1;
foreach($collection->children() as $bd){
if($collection->BD[$i]->titre == $_GET["titre"] && $collection->BD[$i]->annee == $_GET["annee"])
$a = $i;
$i++;
}
if($a >= -1){
unset($collection->BD[$a]);
$collection->asXML("../Information/Collection/".$login.".xml ");
}
Oublié de faire un asXML à la fin !!