Hi, thanks for reading.

I am in way over my head! I am trying to write a shopping cart from scratch.

I am trying to use an xml file to save the cart while the user is shopping. I have called a php page in the head of my html file as follows:

HTML Code:
<script type="text/javascript" src="createXML.php"></script>
The php page creates a session id, creates an xml file of sessionID.xml, and sends the session id back to the page so that my javascript can know the name of the file. This part works. Here is the code for createXML.php:

PHP Code:
session_start(); // start up your PHP session! 
$theSessionID session_id();
touch ($theSessionID.".xml");
echo 
"var thisSessionID=\".$theSessionID.\";"
I then load the file into a dom object on page load, calling my init function and passing it the var thisSessionID. Here is the init():

Code:
function init(IDVariable)
{
    setURL(IDVariable);  // sets global variable urlName == sessionID.xml

    if (window.XMLHttpRequest)
      {      xhttp=new XMLHttpRequest();      }
    else // for older IE 5/6
      {      xhttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    xhttp.open("GET",urlName,false); // open sessionID.xml
    xhttp.send("");
    xmlDoc=xhttp.responseXML;  // sets global variable xmlDoc as xml object == sessionID.xml
 }
I can then manipulate the xml, add and edit nodes, and even display the results. But…I CAN NOT GET THE BLOOMING THING TO SAVE! This is where I am stuck.

I have tried passing the DOM object to another php page using post and the following php code:

PHP Code:
$theURL $_POST["theURL_FromForm"];
$theXML $_POST["theXMLobject_FromForm"];

$fp fopen($theURL,"w");
fputs($fp,$theXML);
fclose($fp); 
It does overwrite the file, but when I open it to see the contents, instead of my xml content, the file is empty except for the words “DOM Object”.

Please help!