replace parts of xml using php

JessicaTJ

New Member
I'm trying to post some data via ajax to a php file which writes some xml. I basically want to post bits of data and replace a certain part of the xml.The js:\[code\]$(".aSave").click(function(){ var name = $(this).attr("data-name"); var value = http://stackoverflow.com/questions/11372880/$(this).attr("data-value"); var dataObj = {}; dataObj[name]=value; $.ajax({ url: 'view/template/common/panel.php', type: 'post', data: dataObj, }).done(function(){ alert("saved!"); });});\[/code\]The php:\[code\]<?php $fruits [] = array( $orangesValue = http://stackoverflow.com/questions/11372880/$_POST['oranges'], $applesValue = http://stackoverflow.com/questions/11372880/$_POST['apples'], ); $doc = new DOMDocument(); $doc->formatOutput = true; $mainTag = $doc->createElement( "fruits" ); $doc->appendChild( $mainTag ); $oranges = $doc->createElement("oranges"); $oranges->appendChild($doc->createTextNode($orangesValue)); $mainTag->appendChild($oranges); $apples = $doc->createElement("apples"); $apples->appendChild($doc->createTextNode($applesValue)); $mainTag->appendChild($apples); echo $doc->saveXML(); $doc->save("fruits.xml")?>\[/code\]So now when I send the oranges value it writes a new xml file containing the oranges value only. Is it possible to replace only the value which i'm posting.Cheers
 
Back
Top