Combine it with an XPath search
<? $xml = simplexml_load_file('employees.xml'); echo $xml->asXML( ); $xml->employee[1]->age = 55; $employees = $xml->xpath('/employees/employee[name="A"]'); $employees[0]->title = "Officer"; echo $xml->asXML( ); ?>