This may be a simple question though can´t figure out how to do it. I want to load and modify an xml file, then save the xml through php.
Here is the code:
$.ajax({
type: "GET",
url: "menu.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('menu_item').each(function(){
//change the value of menu_item
$(this).empty();
$(this).text($("textarea").attr("value"));
//send xml to php
$.post('save_xml.php', $(xml), function(data){alert("Data Loaded: " + data);});
}
}
});
Here is how save_xml.php looks like:
<?php
$xml = $GLOBALS["HTTP_RAW_POST_DATA"];
$file = fopen("file.xml","w");
fwrite($file, $xml);
fclose($file);
echo "ok";
?>