File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / dom / tests / DOMNode_hasChildNodes_basic.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:47:54 2012 UTC (12 years, 5 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

--TEST--
Test whether a node has child nodes: hasChildNodes()
--SKIPIF--
<?php
include('skipif.inc');
?>
--FILE--
<?php 

/* Create an XML document
 * with strcuture
 * <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());

?>
--EXPECTF--
Root has child nodes: bool(true)
Title has child nodes: bool(true)
Text has child nodes: bool(false)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>