1--TEST-- 2Cloning an attribute should retain its namespace 02 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8$dom = new DOMDocument; 9$dom->loadXML(<<<XML 10<?xml version="1.0"?> 11<container xmlns:foo="some:ns" foo:bar="1"> 12 <child xmlns:foo="some:other"/> 13</container> 14XML); 15 16$clone = $dom->documentElement->getAttributeNodeNs("some:ns", "bar")->cloneNode(true); 17$dom->documentElement->firstElementChild->setAttributeNodeNs($clone); 18 19echo $dom->saveXML(); 20 21?> 22--EXPECT-- 23<?xml version="1.0"?> 24<container xmlns:foo="some:ns" foo:bar="1"> 25 <child xmlns:foo="some:other" xmlns:foo1="some:ns" foo1:bar="1"/> 26</container> 27