- simplexml_load_string: documentation ( source)
<?php
$xml=simplexml_load_string(<<<XML
<people>
<person>
</person>
<person id="17">
<name>John</name>
</person>
<person>
</person>
</people>
XML
);
$nodes=$xml->xpath('//person[@id=17]');
$nodes[0]->name="Bill";
echo $xml->asXML();