note 97825 added to class.domxpath
| From: | _michael at osu1 dot php dot net | Date: | Mon, 10 May 2010 21:12:59 +0000 |
| Subject: | note 97825 added to class.domxpath | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-169130@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 (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.
----
Server IP: 85.214.154.209
Probable Submitter: 79.222.33.29
----
Manual Page -- http://www.php.net/manual/en/class.domxpath.php
Edit -- https://master.php.net/note/edit/97825
Del: integrated -- https://master.php.net/note/delete/97825/integrated
Del: useless -- https://master.php.net/note/delete/97825/useless
Del: bad code -- https://master.php.net/note/delete/97825/bad+code
Del: spam -- https://master.php.net/note/delete/97825/spam
Del: non-english -- https://master.php.net/note/delete/97825/non-english
Del: in docs -- https://master.php.net/note/delete/97825/in+docs
Del: other reasons-- https://master.php.net/note/delete/97825
Reject -- https://master.php.net/note/reject/97825
Search -- https://master.php.net/manage/user-notes.php