PHP and simplexml
Posted: Mon Mar 06, 2006 1:54 pm
I cannot seem to manipulate values in a xml document
file named: song.xml
I do this to get the xml into a string:
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?
file named: song.xml
Code: Select all
<?xml version="1.0"?>
<songinfo>
<Artist>Test</Artist>
<Song>fun</Song>
</songinfo>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();
?>