ecrire dans un fichier xml avec php
Bonjour j'ai un fichier xml de type :
Code:
1 2 3 4 5
|
<backstage>
<pic src="img/beauty/thumbnails/beauty-1.jpg" label="Milana Keller" data="img/beauty/beauty-1.jpg"/>
<pic src="img/beauty/thumbnails/beauty-2.jpg" label="Milana Keller" data="img/beauty/beauty-2.jpg"
</backstage> |
je souhaiterais avec un formulaire php ajouter une ligne pic avec src,label et data.
voici mon code php :
Code:
1 2 3 4 5 6 7 8 9 10 11
|
$filename = $chemin_destination.'listing.xml';
$newContent = "\r\t<pic src=\"".$src."\" label=\"".$label."\" data=\"".$data."\"/>";
$newContent .= "\r</pic>";
$content = file_get_contents($filename);
$newContent = str_replace('</pic>', $newContent, $content);
$handle = fopen($filename, 'w');
fwrite($handle, $newContent);
fclose($handle); |
mon code a l'air bon mais ne marche pas, c'est surement une petite erreur a la con sauf que j'y ai passé la matinée:aie:
si quelqu'un peux m'aider ce serais très gentil de sa part merci d'avance