如何通过php / javascript保存javascript字符串中包含的xml

I have xml page contents in a javascript string. I need to save this into my.xml in the server side using php. But i can't seem to pass the xml-content-string value via POST method. I tried file_get_contents and curl but figured out that's not what I want since I have my xml content in string format and not in a file. Can anyone help me to save this string in javascript as proper xml content.

Thanks in advance

Pre

I am attaching my code below

Page1.php

  <form name = "frm_first" method = "POST">
    <input type = "hidden" name = "xml_string">
    ...............


<script type = "text/javascript" language = "javascript">
function getDataXML(){
 xmlString = chart.getDataXML();// This is where I get my xml data into the string
 document.frm_first.xml_string.value = xmlString;
 alert(xml_string); //Good
 document.frm_first.submit();
}
</script>

Page2.php //This is the page to which post is submitted.

    <?php
    echo print_r($_POST);//xml_string vaiable is empty. Other variables are getting displayed.
    $domtree = new DOMDocument('1.0','UTF-8');
    $domtree->loadXML($_POST['xml_string']);// Error :empty string supplied as input
    $domtree->save("my.xml"); //Yes , I have access to the file.
?>

$_POST['xml_string'] is empty is my issue. Other variables are getting passed via POST.

Sorry to be answering my own question, but thought that it might be of use to someone else too. I did a if array_key_exists('xml_string', $_POST)

<?php
if array-_key_exists('xml_string', $_POST) 
{
    echo print_r($_POST);
    $domtree = new DOMDocument('1.0','UTF-8');
    $domtree->loadXML($_POST['xml_string']);
    $domtree->save("my.xml"); 
?>

and now $_POST variables are coming in properly.

Adjusting the header with PHP did the trick when i tried to save a XML file:

header("Content-Disposition: attachment; filename=file.xml");

But sending the XML should be possible as string. Do you get any error messages?