xref: /PHP-7.3/ext/dom/tests/domattributes.phpt (revision b746e698)
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--
38Language: en
39Language: en-US
40Is ID?: NO
41<chapter language="en-US" num="1"/>
42