How can SimpleXML be utilized to modify the structure of an XML file in PHP?

To modify the structure of an XML file in PHP using SimpleXML, you can load the XML file into a SimpleXMLElement object, make the necessary modifications to the object structure, and then save the modified object back to the XML file.

<?php
// Load the XML file into a SimpleXMLElement object
$xml = simplexml_load_file('example.xml');

// Make modifications to the object structure
$xml->addChild('new_element', 'value');
unset($xml->old_element);

// Save the modified object back to the XML file
$xml->asXML('example.xml');
?>