note 48040 deleted from function.dom-domxpath-query by didou

From: Date: Sun, 19 Dec 2004 11:58:29 +0000
Subject: note 48040 deleted from function.dom-domxpath-query by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-82038@lists.php.net to get a copy of this message
Note Submitter: Martin dot Honnen at gmx dot de ---- If you do not provide the second argument, the context node, then by default the context node of the query is the root element node, not the document node. Thus if you have <?php $xmlSource = <<<XMLEND <!-- top level comment --> <?processing-instruction arg="value"?> <root> <child>Kibology</child> <child>PHP</child> </root> XMLEND; $xmlDocument = new DOMDocument(); $xmlDocument->loadXML($xmlSource); $xPathEvaluator = new DOMXPath($xmlDocument); ?> then the following <?php $nodeList = $xPathEvaluator->query('self::node()'); echo 'nodeType: ' . $nodeList->item(0)->nodeType . '; nodeName: ' . $nodeList->item(0)->nodeName ."<br>\r\n"; // nodeType is 1 ?> yields nodeType: 1; nodeName: root while <?php $nodeList = $xPathEvaluator->query('self::node()', $xmlDocument); echo 'nodeType: ' . $nodeList->item(0)->nodeType . '; nodeName: ' . $nodeList->item(0)->nodeName ."<br>\r\n"; // nodeType is 9 ?> yields nodeType: 9; nodeName: #document

« previous php.notes (#82038) next »