1

I am trying to storing multiple form values to xml file using php but here i am able to store only one time posted value.if i post next time it is getting updated.How to make them remain

I am getting values in variables.

$xmlBeg = "<?xml version='1.0' encoding='ISO-8859-1'?>";
     $rootELementStart = "<$u>"; 
     $rootElementEnd = "</$u>"; 
     $xml_document= $xmlBeg; 
     $xml_document .= $rootELementStart;
      $xml_document .= "<box>"; 
        $xml_document .= $con; --//it is getting value of posted
        $xml_document .= "</box>"; 
Shakti Singh
  • 84,385
  • 21
  • 134
  • 153
dferee
  • 11
  • 1
  • So is this a problem of naming the saved file according to user/client specific information...? (ie session, cookie, ip, user agent, etc). Not quite clear yet without more info. – bob-the-destroyer Feb 03 '11 at 05:37

1 Answers1

0

If you are dealing with XML you are better of using one of PHP's XML extensions.

Here is the equivalent of your code with DOM:

$dom  = new DOMDocument('1.0', 'iso-8859-1'); // utf-8 would be better though
$root = $dom->createElement($u);              // create root element
$box  = $dom->createElement('box', $con);     // create box element with content
$root->appendChild($box);                     // make box a child of root
$dom->appendChild($root);                     // make root the document root
echo $dom->save('filename.xml');              // save

This would save the XML in a file called filename.xml.
You can load XML from file with $dom->load('filename.xml').

Also see

Community
  • 1
  • 1
Gordon
  • 312,688
  • 75
  • 539
  • 559