Page 1 of 1

PHP and simplexml

Posted: Mon Mar 06, 2006 1:54 pm
by MasterCephus
I cannot seem to manipulate values in a xml document

file named: song.xml

Code: Select all

<?xml version="1.0"?>
   <songinfo>
     <Artist>Test</Artist>
     <Song>fun</Song>
   </songinfo>
I do this to get the xml into a string:

Code: Select all

<?PHP

$temp = 'song.xml';

if (file_exists($temp)) {
	   $xml = simplexml_load_file($temp);

} else {
	   exit('Failed to open $temp.');
}

$xml->songinfo->Artist = 'NewTest';

echo $xml->asXML();

?>
But when I look at the output, nothing has changed. It seems that I cannot change the values of the XML document. Am I doing something wrong?