I found a lot of tuts here on how to get node with a specified id using XPath, and write down data using SimpleXMLElement::asXML.
But is it possible to write data in the node with specific id
using XPath, but not foreach
method?
Here's what I have
<people>
<person>
...
</person>
<person id="17">
<name>John</name>
</person>
<person>
...
</person>
</people>
I'm looking something like:
$xml->person['id=17']->name = Bill;
or
$xml->xpath('/person[@id=17]')->name = Bill;
and then
$xml->asXML(data.xml);