PHP and simplexml

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MasterCephus
Forum Newbie
Posts: 3
Joined: Thu Jun 30, 2005 2:49 pm

PHP and simplexml

Post 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?
Post Reply