[XML] [DOM(XML?)] Suppression d'un noeud XML en php
Bonjour,
Voici le code qui me sert à supprimer un noeud dont l'identifiant est passé en paramètre :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
$doc = new DOMDocument();
$doc -> load('../bandeauDiapo.xml');
$animations = $doc->documentElement;
$anim = $animations->getElementsByTagName("animation");
foreach($anim as $animation)
{
if ($animation->hasAttribute("id") == $_GET['ID_animation'])
{
if ($animation->getAttribute("id") == $_GET['ID_animation'])
{
//print_r($animation);
$animations->removeChild($animation);
}
}
}
echo $doc->saveXML(); |
Mon seul soucis c'est qu'à l'affichage du echo $doc->saveXML, la suppression est bonne cependant cela n'est pas enregistré dans mon fichier. Le noeud est toujours présent dans mon arborescence xml.
Comment puis-je enregistrer le fichier xml ??
Merci d'avance