1--TEST--
2Element::getAttribute()
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];
12var_dump($body->getAttribute("align"));
13var_dump($body->getAttribute("foo:bar"));
14
15echo "--- Get after creating without namespace ---\n";
16
17$body->setAttributeNode($attr = $dom->createAttribute("prefix:local"));
18$attr->value = "A";
19var_dump($body->getAttribute("prefix:local"));
20
21echo "--- Get after creating with namespace ---\n";
22
23$body->setAttributeNode($attr = $dom->createAttributeNS("urn:a", "prefix:local2"));
24$attr->value = "B";
25var_dump($body->getAttribute("prefix:local2"));
26var_dump($body->getAttribute("Prefix:LOCAL2"));
27
28echo "--- Get after creating with namespace case sensitive ---\n";
29
30$element = $dom->createElementNS("urn:a", "a:element");
31$attr = $dom->createAttributeNS("urn:a", "Prefix:local2");
32$element->setAttributeNode($attr);
33$attr->value = "C";
34var_dump($element->getAttribute("Prefix:local2"));
35var_dump($element->getAttribute("Prefix:LOCAL2"));
36var_dump($element->getAttribute("prefix:local2"));
37
38?>
39--EXPECT--
40--- Get after parsing ---
41string(3) "foo"
42string(3) "baz"
43--- Get after creating without namespace ---
44string(1) "A"
45--- Get after creating with namespace ---
46string(1) "B"
47string(1) "B"
48--- Get after creating with namespace case sensitive ---
49string(1) "C"
50NULL
51NULL
52