View Single Post
Old 01-18-2008, 06:30 PM   #5 (permalink)
buildakicker
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Default

Thanks for the responces. I found an article and have followed it, however, it's overwriting my data, not appending to it.

Here's my form post code:
PHP Code:
<?php
if(isset($_POST['newpost'])){
    
//get the info from the form, post to text file.
    
$ptitle stripslashes($_POST['title']);
    
$pcategory stripslashes($_POST['category']);
    
$pbody stripslashes($_POST['body']);

//################### XML #################################    

 //Creates XML string and XML document using the DOM 
 
$dom = new DomDocument('1.0'); 
 
//add root - <posts> 
 
$posts $dom->appendChild($dom->createElement('posts')); 
 
//add <post> element to <posts> 
 
$post $posts->appendChild($dom->createElement('post')); 
 
//add <title> element to <post> 
 
$title $post->appendChild($dom->createElement('title')); 
  
//add <category> element to <post> 
 
$category $post->appendChild($dom->createElement('category')); 
  
//add <body> element to <post> 
 
$body $post->appendChild($dom->createElement('body')); 
  
//add <pubDate> element to <post> 
 
$pubDate $post->appendChild($dom->createElement('pubDate')); 
 
//add <title> text node element to <title> 
 
$title->appendChild
                 
$dom->createTextNode($ptitle)); 
 
$category->appendChild
                 
$dom->createTextNode($pcategory)); 
 
$body->appendChild
                 
$dom->createTextNode($pbody)); 
 
$pubDate->appendChild
                 
$dom->createTextNode($todaysdate)); 
 
//generate xml 
 
$dom->formatOutput true// set the formatOutput attribute of 
                            // domDocument to true 
 // save XML as string or file 
 
$test1 $dom->saveXML(); // put string in test1 
 
$dom->save('posts.xml'); // save as file 

########## XML END ##########################################
    
$postupdated "You have created a new post!";
}
?>
Do I need to store the current file in a variable somehow?
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote