J'ai un gros problème depuis quelques jours.....
Je dois editer un fichier xml utilisé par un player mp3. Ce fichier contient en effet les titres à diffuser.
CODE
<?xml version="1.0" encoding="UTF-8"?>
<player showDisplay="yes" showPlaylist="no" autoStart="yes">
<song path="album/titre1.mp3" title="titre 1" />
<song path="album/titre2.mp3" title="titre 2" />
<song path="album/titre3.mp3" title="titre 3" />
</player>
<player showDisplay="yes" showPlaylist="no" autoStart="yes">
<song path="album/titre1.mp3" title="titre 1" />
<song path="album/titre2.mp3" title="titre 2" />
<song path="album/titre3.mp3" title="titre 3" />
</player>
Par le biais de la fonction file je met tout le contenu dans un tableau. Maintenant je dois trouver la ligne du tableau et la supprimer ....
Voilà mon code qui de fonctionne pas ....
CODE
$lines = file ('player.xml');
$path = '<song path="album/titre2.mp3" title="titre 2" />';
$path = htmlspecialchars("$path", ENT_QUOTES);
// Affiche toutes les lignes du tableau, avec les numeros de ligne
foreach ($lines as $line_num => $line) {
$line = htmlspecialchars("$line", ENT_QUOTES);
if ($line != $path) {
echo "Ligne No <strong>" . $line_num . "</strong> : " . $line . "<br />"."\n";
}
}
$path = '<song path="album/titre2.mp3" title="titre 2" />';
$path = htmlspecialchars("$path", ENT_QUOTES);
// Affiche toutes les lignes du tableau, avec les numeros de ligne
foreach ($lines as $line_num => $line) {
$line = htmlspecialchars("$line", ENT_QUOTES);
if ($line != $path) {
echo "Ligne No <strong>" . $line_num . "</strong> : " . $line . "<br />"."\n";
}
}
$path étant la chaine que je dois trouver ....
pour info je suis pas encore sous php5 et je ne tiens pas à me mettre à parser le xml etant donné que les heures sont comptées...
Merci pour votre aide.... la ca devient super super urgent.... et je tourne en rond