Prevent save() from overwriting dtd in an xml file

Alexis_Arizona

New Member
I'm writing a script that adds nodes to an xml file. In addition to this I have an external dtd I made to handle the organization to the file. However the script I wrote keeps overwriting the dtd in the empty xml file when it's done appending nodes. How can I stop this from happening?Code:\[code\]<?php/*Dom vars*/$dom = new DOMDocument("1.0", "UTF-8");$previous_value = http://stackoverflow.com/questions/10441475/libxml_use_internal_errors(TRUE);$dom->load('post.xml');libxml_clear_errors();libxml_use_internal_errors($previous_value);$dom->formatOutput = true;$entry = $dom->getElementsByTagName('entry');$date = $dom->getElementsByTagName('date');$para = $dom->getElementsByTagname('para');$link = $dom->getElementsByTagName('link');/* Dem POST vars used by dat Ajax mah ziggen, yeah boi*/if (isset($_POST['Text'])){$text = trim($_POST['Text']);}/*function post(){ global $dom, $entry, $date, $para, $link, $home, $about, $contact, $text;*/ $entryC = $dom->createElement('entry'); $dateC = $dom->createElement('date', date("m d, y H:i:s")) ; $entryC->appendChild($dateC);$tab = "\n";$frags = explode($tab, $text);$i = count($frags);$b = 0;while($b < $i){$paraC = $dom->createElement('para', $frags[$b]);$entryC->appendChild($paraC);$b++;}$linkC = $dom->createElement('link', rand(100000, 999999));$entryC->appendChild($linkC);$dom->appendChild($entryC);$dom->save('post.xml');/*}post();*/echo 1;?>\[/code\]
 
Back
Top