Update XML node keeps adding value instead of uppdating

normanb

New Member
I cant seem to get this query right...What I'm trying to achieve is.update the value insise my text node.But the problem is that instead of updating the value it keeps adding value to the element.say i $_post 'Hello' to the value. It adds valuee. But later I want to change the value 'Hello' to 'God Bye' instead of modify the node it ads 'Hello God Bye'I have tried Im using PHP DOM. But cant seem to get it with simple xml eather.Any suggestions ? This is what i have for now\[code\]<?php $xml = new DOMDocument(); $xml->formatOutput = TRUE; $xml->preserveWhiteSpace = FALSE; $xml->load('../stickers.xml'); $xpath = new DOMXPath($xml);// $result = $xpath->query('/stickers/sticker[id='.$_POST['textBoxID'].']/text');$result = $xpath->query('/stickers/sticker[id="559428"]/text');$result->item(0)->nodeValue .= 'Hello';// $result->item(0)->nodeValue .= $_POST['textBox']; echo $xml->saveXML(); $xml->save('../stickers.xml');\[/code\]
 
Back
Top