EKsparky Posted February 2, 2008 Share Posted February 2, 2008 Hi ive created a basic admin panel for a friends website so he can add news, pictures to a gallary and calander Heres my problem i want for him to be able to add dates and content to calendar via html form I've searched for hours on how to add new nodes to xml form tried a few different tutorials and scripts out but with no luck. Any help would be greatly appreciated My xml is as follows <calendar> <event> <date>2008-01-01</date> <title>New Year's Day</title> <url></url> </event> <event> <date>2008-02-05</date> <title>Test</title> <url></url> </event> </calendar> this is the sort php code i seem to be finding to add nodes <?php #load an XML document into the DOM $dom -> load( "calendar.xml" ); // create root element $root = $dom->createElement("event"); $dom->appendChild($root); // create child element $date = $dom->createElement("date"); $root->appendChild($date); $title = $dom->createElement("title"); $root->appendChild($title); $url = $dom->createElement("url"); $root->appendChild($url); // create text node $text_date = $dom->createTextNode("2008-02-10"); $date->appendChild($text_date); $text_title = $dom->createTextNode("testing"); $title->appendChild($text_title); $text_url = $dom->createTextNode("www.need-help.com"); $url->appendChild($text_url); // save and display tree $dom-> save ("calendar.xml"); ?> I assumed that if that worked i would just change date text and url with vars from html form Ive chmod 777 .xml Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/89048-php-xml/ 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.