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.