Model structured documents with elements, attributes, namespaces, schemas, parsing, and transformations.
Lessons
Map XML to and from program objects.
XML Data Binding is easiest to learn by reading the example, changing it, and observing the result.
<?php
// Bind XML to a typed object
$xml = simplexml_load_string($source);
$lesson = (object) [
'title' => (string) $xml->title,
'minutes' => (int) $xml->minutes,
'level' => (string) $xml['level'],
];
print_r($lesson);Practice the XML Data Binding example in a small scratch file, then explain what changed and why.