1--TEST-- 2DOMElement::getAttributeNames() 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8function test($str) { 9 $dom = new DOMDocument(); 10 $dom->loadXML($str); 11 var_dump($dom->documentElement->getAttributeNames()); 12 foreach ($dom->documentElement->getAttributeNames() as $name) { 13 assert($dom->documentElement->getAttributeNode($name)->nodeName === $name); 14 } 15} 16 17test('<html xmlns:some="some:ns" some:test="a" test2="b"/>'); 18test('<html test="b" test3="c"/>'); 19test('<html/>'); 20 21?> 22--EXPECT-- 23array(3) { 24 [0]=> 25 string(10) "xmlns:some" 26 [1]=> 27 string(9) "some:test" 28 [2]=> 29 string(5) "test2" 30} 31array(2) { 32 [0]=> 33 string(4) "test" 34 [1]=> 35 string(5) "test3" 36} 37array(0) { 38} 39