callison Posted August 7, 2008 Share Posted August 7, 2008 Hi, I have an xml file that is supposed to hold information for my offices software library. I have a simple form with 7-8 fields that makes a single line xml entry like: <software software_number="5" department="it" dev="adobe" prod="dreamweaver" sn="1234" pass="234" machine="it3" date="08-07-2008">Comments</software> Of course theres also a look up script, and a form to edit the entry. But if I go to edit the form... function updateSoft() { $xmlstr = file_get_contents('software.xml'); $xml = new XMLElement($xmlstr); $id = strtolower($_POST['id']); $dev = strtolower($_POST['dev']); $prod = strtolower($_POST['prod']); $sn = strtolower($_POST['sn']); $pass = strtolower($_POST['pass']); $machine = strtolower($_POST['machine']); $dept = strtolower($_POST['dept']); $comments = strtolower($_POST['comments']); $update = $xml->xpath("//software[starts-with(@software_number, '".$id."')]"); $update[0]['dev'] = $dev; $update[0]['prod'] = $prod; $update[0]['department'] = $dept; $update[0]['sn'] = $sn; $update[0]['pass'] = $pass; $update[0]['machine'] = $machine; $update[0] = $comments; $xmlfile = fopen('software.xml', 'w'); fwrite($xmlfile, $xml->asPrettyXML()); fclose($xmlfile); echo "<br /><br /><a href='index.php'>Click here, go home</a>"; } This is the function that handles the incoming form, and updating the XML file. Everything works good, but this line: $update[0] = $comments; Trying to update the comments doesn't work like I thought it would. What am I doing wrong? Let me know if more explanation / code is needed. Link to comment https://forums.phpfreaks.com/topic/118625-simplexml-question/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.