note 97878 added to class.domxpath

From: Date: Thu, 13 May 2010 13:18:40 +0000
Subject: note 97878 added to class.domxpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-169208@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.197 Probable Submitter: 79.222.33.178 ---- Manual Page -- http://www.php.net/manual/en/class.domxpath.php Edit -- https://master.php.net/note/edit/97878 Del: integrated -- https://master.php.net/note/delete/97878/integrated Del: useless -- https://master.php.net/note/delete/97878/useless Del: bad code -- https://master.php.net/note/delete/97878/bad+code Del: spam -- https://master.php.net/note/delete/97878/spam Del: non-english -- https://master.php.net/note/delete/97878/non-english Del: in docs -- https://master.php.net/note/delete/97878/in+docs Del: other reasons-- https://master.php.net/note/delete/97878 Reject -- https://master.php.net/note/reject/97878 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169208) next »