xref: /php-src/ext/dom/tests/DOM4_ParentNode.phpt (revision bd9f4fa6)
1--TEST--
2DOMParentNode: Child Element Handling
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7require_once("dom_test.inc");
8
9$dom = new DOMDocument;
10$dom->loadXML('<test>foo<bar>FirstElement</bar><bar>LastElement</bar>bar</test>');
11
12var_dump($dom instanceof DOMParentNode);
13print_node($dom->firstElementChild);
14print_node($dom->lastElementChild);
15var_dump($dom->childElementCount);
16
17$element = $dom->documentElement;
18var_dump($element instanceof DOMParentNode);
19print_node($element->firstElementChild);
20print_node($element->lastElementChild);
21var_dump($element->childElementCount);
22var_dump($element->lastElementChild->firstElementChild);
23var_dump($element->lastElementChild->lastElementChild);
24var_dump($element->lastElementChild->childElementCount);
25?>
26--EXPECT--
27bool(true)
28Node Name: test
29Node Type: 1
30Num Children: 4
31
32Node Name: test
33Node Type: 1
34Num Children: 4
35
36int(1)
37bool(true)
38Node Name: bar
39Node Type: 1
40Num Children: 1
41Node Content: FirstElement
42
43Node Name: bar
44Node Type: 1
45Num Children: 1
46Node Content: LastElement
47
48int(2)
49NULL
50NULL
51int(0)
52