Hi
the following xml fragment is generated from the php code below
<?xml version="1.0"?>
<result rest_id="an1">
<answer_text>answer</answer_text>
<desc-result>descriptions</desc-result>
<result>
Every time the user comes to the page the new data will override the current one
i need to append the new data to the end of current one
keeping the xml file well formed
thanks
session_start();
$new= $GET['new'];
$dom1 = new DOMDocument;
$dom1->Load('test.xml');
$xpath = new DOMXPath($dom1);
$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;
}
$dom2 = new DomDocument;
$parent_node = $dom2->createElement('result');
$attr = $parent_node->setAttributeNode(new DOMAttr('rest_id',$attrt));
$parent_node->appendChild($dom2->createElement('answer_text',$answer_text));
$parent_node->appendChild($dom2->createElement('desc-result',$desc_result));
$dom2->appendChild($parent_node);
//create a file with the session id name
$dom2->save(session_id().'.xml');