I cant seem to get this query right. What I'm trying to achieve is:
Update the value inside my text node.
But the problem is that instead of updating the value it keeps adding the value to the element.
Say I $_POST 'Hello' to the value. It adds value. But later I want to change the value 'Hello'
to 'God Bye'
instead of modify the node to 'Hello God Bye'
.
I have tried I'm using PHP DOM. But can't seem to get it with SimpleXML either.
Any suggestions ?
This is what I have for now:
$xml = new DOMDocument();
$xml->formatOutput = TRUE;
$xml->preserveWhiteSpace = FALSE;
$xml->load('../stickers.xml');
$xpath = new DOMXPath($xml);
$result = $xpath->query('/stickers/sticker[id="559428"]/text');
$result->item(0)->nodeValue .= 'Hello';
echo $xml->saveXML();
$xml->save('../stickers.xml');