Combine it with an XPath search : xpath « XML « PHP






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( );
?>
  
  








Related examples in the same category

1.xpath.php
2.Using XPath and DOM
3.Using XPath and SimpleXML in a basic example
4.Using XPath with DOM in a basic example
5.Using XPath with SimpleXML in a more complicated example
6.XPath DOM Query
7.XPath can be used to filter your results according to any values
8.Searching and Filtering with XPath