1--TEST-- 2Element::getAttributeNodeNS() 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8echo "--- Get after parsing ---\n"; 9 10$dom = Dom\HTMLDocument::createFromString('<!DOCTYPE html><html><body align="foo" foo:bar="baz"></body></html>'); 11$body = $dom->getElementsByTagName("body")[0]; 12 13echo "--- After parsing, i.e. without namespace ---\n"; 14 15// Every pair of 2 calls should return the same result 16var_dump($body->getAttributeNodeNS(NULL, "align")->textContent); 17var_dump($body->getAttributeNodeNS("", "align")->textContent); 18var_dump($body->getAttributeNodeNS(NULL, "ALIGN")); 19var_dump($body->getAttributeNodeNS("", "ALIGN")); 20var_dump($body->getAttributeNodeNS(NULL, "foo:bar")->textContent); 21var_dump($body->getAttributeNodeNS("", "foo:bar")->textContent); 22var_dump($body->getAttributeNodeNS(NULL, "FOO:BAR")); 23var_dump($body->getAttributeNodeNS("", "FOO:BAR")); 24 25echo "--- Special legacy case ---\n"; 26 27var_dump($dom->documentElement->getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "xmlns")); 28 29echo "--- Get after creating without namespace ---\n"; 30 31$body->setAttributeNode($attr = $dom->createAttribute("prefix:local")); 32$attr->value = "A"; 33var_dump($body->getAttributeNodeNS(NULL, "prefix:local")->textContent); 34var_dump($body->getAttributeNodeNS(NULL, "prefix:LOCAL")); 35 36echo "--- Get after creating with namespace ---\n"; 37 38$body->setAttributeNode($attr = $dom->createAttributeNS("urn:a", "prefix:local2")); 39$attr->value = "B"; 40var_dump($body->getAttributeNodeNS("urn:a", "local2")->textContent); 41var_dump($body->getAttributeNodeNS("urn:a", "LOCAL2")); 42 43?> 44--EXPECT-- 45--- Get after parsing --- 46--- After parsing, i.e. without namespace --- 47string(3) "foo" 48string(3) "foo" 49NULL 50NULL 51string(3) "baz" 52string(3) "baz" 53NULL 54NULL 55--- Special legacy case --- 56NULL 57--- Get after creating without namespace --- 58string(1) "A" 59NULL 60--- Get after creating with namespace --- 61string(1) "B" 62NULL 63