View Single Post
  #3 (permalink)  
Old 05-16-09, 09:30 AM
mogant0 mogant0 is offline
Newbie Coder
 
Join Date: May 2009
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Hooraaaahh heres the code

Thanks you are a star . . . .couldnt see the woods for the trees when looking at examples i found
Anyhow thanks again this is the test code i've setup

PHP Code:

<?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_xmltrue);
  
$dom_xml $dom->appendChild($dom_xml);
  print 
$dom->save("calendar.xml")
?>
I do be a very happy bunny
mogant
Reply With Quote