Jump to content

PHP XML


EKsparky

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.