Jump to content


php simple xml

  • Please log in to reply
No replies to this topic

#1 sso

  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 08 September 2006 - 08:34 AM

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('done', 0);
    $newTask->addChild('toDo', $toDo);

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,

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users