note 97825 deleted from class.domxpath by danbrown

From: Date: Mon, 10 May 2010 21:14:14 +0000
Subject: note 97825 deleted from class.domxpath by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169131@lists.php.net to get a copy of this message
Note Submitter: _ michael ---- The solution proposed below by 'ahsdg at NOSPAM dot pochta dot ru' does not work (try it). If you register a prefix for a default namespace, you obviously must use it in the XPath query - that's what the registering of a prefix is all about. So <?php $xp = new DOMXPath($domDoc); $xp->registerNamespace('x', 'http://www.w3.org/1999/xhtml'); ?> implies an XPath query using 'x' as a prefix for all elements living in the default namespace: <?php $xpathString = "/x:html/x:body/*[@class='text']"; ?> By contrast, $xpathString = "/html/body/*[@class='text']" will not yield any results. In OO terms, it would make much more sense to implement a class xpathExtension as precisely that - a class extending DOMXPath.

« previous php.notes (#169131) next »