hi
i made some progress to the code and the problem 99% solved
the only thing is to solve is the following :
as you know fopen() with
works if the file exists but in my case i need to write to a file which will take the session id name in onther word the file dose not exixts yet , i tried with
but the code dose not work for some reasone
if we can find the problem for that would be fab
and thanks
<?php
session_start();
$new= $HTTP_GET_VARS['new'];
$doc = new DOMDocument;
$doc->Load('Test.xml');
$xpath = new DOMXPath($doc);
$query = "//answer[@an_id = '$new']";
$entries = $xpath->query($query);
foreach ($entries as $entry) {
$attrt=$entry->getAttribute('an_id');
$answer_text=$entry->childNodes->item(0)->nodeValue;
$desc_result=$entry->childNodes->item(1)->nodeValue;
}
$dom = new DomDocument;
$parent_node = $dom ->createElement('result');
$attr = $parent_node->setAttributeNode(new DOMAttr('rest_id',$attrt));
$parent_node->appendChild($dom->createElement('answer_text',$answer_text));
$parent_node->appendChild($dom->createElement('desc-result',$desc_result));
$dom->appendChild($parent_node);
$contents= $dom->saveXML($parent_node);
// the problem
$file_handle = fopen(session_id().'.xml','r+');
fseek($file_handle,-10,SEEK_END);
fwrite($file_handle,$contents.'</results>');
fclose($file_handle);
?>