<?php // Here am loading up the original calendar xml file $file = "calendar.xml"; //this will actualy be passed when php is invoced $xml = simplexml_load_file($file); //create the simplexml // Here am emulating form fields coming in for attributes and event node // And changing the contents of these in the simplexml string. Will have // identified the occurance of date i wanna change and passed this through too // in this case have hard coded the first element ie:[0] $formyear = "2009"; $formmonth = "5"; $formday = "16"; $formevent = "The day I did it"; $xml->once->date[0]['year'] = $formyear; $xml->once->date[0]['month'] = $formmonth; $xml->once->date[0]['day'] = $formday; $xml->once->date[0]->event = $formevent; // convert to DOM so we can rewrite the calendar xml file. $dom_xml = dom_import_simplexml($xml); $dom = new DomDocument(); $dom_xml = $dom->importNode($dom_xml, true); $dom_xml = $dom->appendChild($dom_xml); print $dom->save("calendar.xml") ?>