note 43631 added to ref.dom

From: Date: Mon, 28 Jun 2004 16:53:42 +0000
Subject: note 43631 added to ref.dom
Groups: php.notes 
Request: Send a blank email to php-notes+get-72062@lists.php.net to get a copy of this message
Use 'nodeType' to get the type of a node. Returns value of the predefined XML constants listed above. Example: - You can use the following xml-structure (name it structure.xml): <?xml version="1.0"?> <foo><bar><text>DOM in PHP5 is good.</text><text>Hello.</text></bar></foo> - The code: <?php $document = new DomDocument(); $document->preserveWhiteSpace = false; $document->load("structure.xml"); $xpath = new domXPath($document); $xpathQuery = $xpath->query("/foo/bar/text[position()=1]"); foreach ($xpathQuery as $nodeList) { if($nodeList->firstChild->nodeType==XML_TEXT_NODE) echo "Node is a piece of text.<br />"; } ?> Dominikus Wetzel ---- Manual Page -- http://www.php.net/manual/en/ref.dom.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43631 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43631&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43631&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#72062) next »