This changes the qualified name of my-attr to
my-new-attr and also changes its namespace to
urn:my-ns.
<?php
$doc = Dom\XMLDocument::createFromString('<root my-attr="value"/>');
$root = $doc->documentElement;
$attribute = $root->attributes['my-attr'];
$attribute->rename('urn:my-ns', 'my-new-attr');
echo $doc->saveXml();
?>
The above example will output:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:ns1="urn:my-ns" ns1:my-new-attr="value"/>