xref: /PHP-7.0/ext/dom/tests/domattributes.phpt (revision e94670d4)
1--TEST--
2Attributes: DOMAttribute functionality
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7require_once("dom_test.inc");
8
9$dom = new DOMDocument;
10$dom->loadXML($xmlstr);
11if(!$dom) {
12  echo "Error while parsing the document\n";
13  exit;
14}
15
16$node = $dom->documentElement;
17
18$lang = $node->getAttributeNode('language');
19echo "Language: ".$lang->value."\n";
20
21$lang->value = 'en-US';
22echo "Language: ".$lang->value."\n";
23
24$parent = $lang->ownerElement;
25
26$chapter = new DOMAttr("num", "1");
27$parent->setAttributeNode($chapter);
28
29echo "Is ID?: ".($chapter->isId()?'YES':'NO')."\n";
30
31$top_element = $node->cloneNode();
32
33print $dom->saveXML($top_element);
34
35
36?>
37--EXPECT--
38
39Language: en
40Language: en-US
41Is ID?: NO
42<chapter language="en-US" num="1"/>
43
44