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