blob: b4da4a48aa10704b27f4a51a580ec4381130dbd2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
--TEST--
Test whether a node has child nodes: hasChildNodes()
--SKIPIF--
<?php
include('skipif.inc');
?>
--FILE--
<?php
/* Create an XML document
* with structure
* <book>
* <title>This is the title</title>
* </book>
* Check for child nodes of the <book>, <title> and This is the title
*
*/
$doc = new DOMDocument();
$root = $doc->createElement('book');
$doc->appendChild($root);
$title = $doc->createElement('title');
$root->appendChild($title);
$text = $doc->createTextNode('This is the title');
$title->appendChild($text);
echo "Root has child nodes: ";
var_dump($root->hasChildNodes());
echo "Title has child nodes: ";
var_dump($title->hasChildNodes());
echo "Text has child nodes: ";
var_dump($text->hasChildNodes());
?>
--EXPECT--
Root has child nodes: bool(true)
Title has child nodes: bool(true)
Text has child nodes: bool(false)
|