I'm trying to change the value of one of the attributes, in this example just the value for "annotation". (The name of the song)<?xml version="1.0" encoding="UTF-8"?>
<playlist version="0" xmlns = "http://xspf.org/ns/0/">
<title>Xeroform on Want-Signed.com</title>
<trackList>
<track>
<location>http://www.want-signed.com/artists/xeroform/Drown You.mp3</location>
<image>http://www.want-signed.com/artists/xero ... jpg</image>
<annotation>Drown You</annotation>
</track>
<track>
<location>http://www.want-signed.com/artists/xero ... </location>
<image>http://www.want-signed.com/artists/xero ... jpg</image>
<annotation>Rebate</annotation>
</track>
<track>
<location>http://www.want-signed.com/artists/xeroform/Mary Cover.mp3</location>
<image>http://www.want-signed.com/artists/xero ... jpg</image>
<annotation>Mary Cover</annotation>
</track>
</trackList>
</playlist>
Code: Select all
<?php
$artist= $_GET["artist"];
$songnumber= $_GET["song_number"];
$newsongname= $_POST["newname"];
$root = $_SERVER['DOCUMENT_ROOT'];
$file = $root . "/whereallmyxspffilesare/" . $artist . ".xspf";
$xml = simplexml_load_file($file) or die ("Unable to load XML file!");
$xml->trackList[0]->track[$songnumber]->annotation = $newsongname;
$fh = fopen($file, "w+");
fwrite($fh, $xml->asXML() );
fclose($fh);
$songnumber++;
echo "Song number " . $songnumber . " name changed to " . $newsongname;
?>
The problem is on line 9 I know that much.
*I've read about a thousand tutorials and I can't figure out what's wrong*