How can the PHP DOMDocument class be utilized to edit specific elements within an XML document?
The PHP DOMDocument class can be utilized to edit specific elements within an XML document by loading the XML file, navigating to the desired element using XPath, making the necessary modifications, and then saving the updated XML document.
$doc = new DOMDocument();
$doc->load('example.xml');
$xpath = new DOMXPath($doc);
$element = $xpath->query('//element[@id="123"]')->item(0);
$element->setAttribute('attribute', 'new_value');
$doc->save('example.xml');