note 45904 deleted from function.dom-domxpath-query by aidan

From: Date: Thu, 23 Sep 2004 08:28:46 +0000
Subject: note 45904 deleted from function.dom-domxpath-query by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77224@lists.php.net to get a copy of this message
Note Submitter: ude.uhj@namdlogmas ---- On my PHP 5.0.1 install XPath seems to return an empty DOMNodeList no matter what if the root element has attributes. <?php $data = <<<XML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>DOM is pretty cool!</title></head> <body /> </html> XML; $doc = DOMDocument::loadXML($data); $xpath = new DOMXPath($doc); $nodeList = $xpath->query("//body"); // same result any XPath query echo $nodeList->length; //output is 0 ?> <?php $data = <<<XML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head><title>DOM is pretty cool!</title></head> <body /> </html> XML; $doc = DOMDocument::loadXML($data); $xpath = new DOMXPath($doc); $nodeList = $xpath->query("//body"); // same result any XPath query echo $nodeList->length; //output is 1 ?>

« previous php.notes (#77224) next »