I want to set text of some node found by xpath()
text
The real answer is: you kind of can't.
On the other hand you can use DOM for it, e.g.
dom_import_simplexml($node)->nodeValue = 'foo';