$xml = simplexml_load_file('books.xml'); foreach ($xml->book as $book) { echo $book->title . "
"; }
$xml = <<In this example, we explicitly call the children function to retrieve the "name" and "salary" elements. The SimpleXMLElement class is part of the PHP standard library and requires no additional package or library.John Doe 50000 XML; $employee = simplexml_load_string($xml); $name = $employee->name; $salary = $employee->salary; echo $name . " earns " . $salary . " a year.";