fonction str_replace indefinie
bonjour je voudrais remplacer des balises xml dans un fichier kml (format xml de google earth) mais j'ai un petit souci mon code me renvoie l'erreur suivante : Undefined variable: newkml
voici mon code
Code:
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
| <?php
$fp = fopen("test_str_replace.kml", "a+" );
$kml= "
<Placemark>
<name>IUT Carcassonne</name>
<description>ajout de point </description>
<Point>
<coordinates>2.342303,43.188986</coordinates>
</Point>
</Placemark>
";
$new = htmlentities($kml) ;
$newkml = str_replace('</document></kml>', $new .'</document></kml>',$newkml ) ;
echo $new;
fclose($fp); |
voici le code du fichier kml dans lequel j'écris
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| <?xml version="1.0"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<Placemark>
<name>IUT Carcassonne</name>
<description>ajout de point </description>
<Point>
<coordinates>2.342303,43.188986</coordinates>
</Point>
</Placemark>
</document>
</kml> |
Pouvez vous m'aidez?