Is there a way to retrieve all attributes from XML elements in PHP DOM, and if so, what is the process for doing this?

To retrieve all attributes from XML elements in PHP DOM, you can use the `getAttributeNode` method to get a list of attributes for a specific element. You can then loop through this list to retrieve the attribute names and values.

// Load the XML file
$xml = new DOMDocument();
$xml->load('example.xml');

// Get all elements in the XML
$elements = $xml->getElementsByTagName('*');

// Loop through each element and retrieve its attributes
foreach ($elements as $element) {
    if ($element->hasAttributes()) {
        foreach ($element->attributes as $attr) {
            $attrName = $attr->nodeName;
            $attrValue = $attr->nodeValue;
            echo "Attribute: $attrName, Value: $attrValue\n";
        }
    }
}