note 97878 deleted from class.domxpath by danbrown

From: Date: Thu, 13 May 2010 13:42:56 +0000
Subject: note 97878 deleted from class.domxpath by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169209@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 (and yes, I've tried). If you register a prefix for a default namespace, you 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']"; ?> This will work. By contrast, $xpathString = "/html/body/*[@class='text']" will not yield any results.

« previous php.notes (#169209) next »