src/SimpleDOM.php
public function copyAttributesFrom(SimpleXMLElement $src, $overwrite = true)
    {
        $dom = dom_import_simplexml($this);

        foreach (dom_import_simplexml($src)->attributes as $attr) {
            if ($overwrite
                || !$dom->hasAttributeNS($attr->namespaceURI, $attr->nodeName)
            ) {
                $dom->setAttributeNS($attr->namespaceURI, $attr->nodeName, $attr->nodeValue);
            }
        }

        return $this;
    }
public function copyAttributesFrom(SimpleXMLElement $src, $overwrite = true)
    {
        $dom = dom_import_simplexml($this);

        foreach (dom_import_simplexml($src)->attributes as $attr) {
            if ($overwrite
                || !$dom->hasAttributeNS($attr->namespaceURI, $attr->nodeName)
            ) {
                $dom->setAttributeNS($attr->namespaceURI, $attr->nodeName, $attr->nodeValue);
            }
        }

        return $this;
    }
Copy all attributes from a node to current node

@param    SimpleXMLElement $src Source node
@param    bool $overwrite If TRUE, overwrite existing attributes.
Otherwise, ignore duplicate attributes
@return    SimpleDOM                        Current node