What is the difference between using domxml and DOM extension in PHP for handling XML files?

The main difference between using domxml and the DOM extension in PHP for handling XML files is that domxml is a legacy extension that has been deprecated since PHP 5.0, while the DOM extension is the recommended and more modern approach for working with XML files in PHP. The DOM extension provides a more robust and object-oriented way to manipulate XML documents compared to domxml.

// Example of using the DOM extension to parse an XML file
$xml = new DOMDocument();
$xml->load('example.xml');

// Accessing the root element
$root = $xml->documentElement;

// Looping through child nodes
foreach ($root->childNodes as $node) {
    echo $node->nodeName . ': ' . $node->nodeValue . "\n";
}