sso Posted September 8, 2006 Share Posted September 8, 2006 Hey all,I am writing a php-gtk app and I am reading a xml file in to represent the users todo list. My problem is i can read the file in fine, but i do not know how to change the xml file when the user changes part of it..here is a little bit of code..function create_tree() { //------------------load the tasks ------------------ $toDoList = simplexml_load_file('list2.xml'); //-------------------end loading tasks -------------- //add some data to the data store foreach ($toDoList->task as $task) { // i add stuff to show it on the screen } }... these code here will allow me to add or append to the xml file$toDoList = simplexml_load_file('list2.xml'); $index = 0; foreach ($toDoList->task as $task) { $intID = (int)$task->id; if ($index <= $intID) { $index = $intID +1; } } echo $index; $newTask = $toDoList->addChild('task'); $newTask->addChild('id',$index); $newTask->addChild('done', 0); $newTask->addChild('toDo', $toDo); $newTask->addChild('priority',$priority); $newTask->addChild('date',$dateString); file_put_contents('list2.xml',$toDoList->asXML());But what i am really hoping for is to be able to edit the xml file so when the user clicks done on a certain task I can write that to xml .Would appreciate any ideas or directions on where to go.Kind regards,Sso Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.