#11903 [Com]: xpath_eval does not work with default namespace.
| From: | sex-amateur1838 at hotmail dot com | Date: | Tue, 20 Jul 2004 15:08:45 +0000 |
| Subject: | #11903 [Com]: xpath_eval does not work with default namespace. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-63098@lists.php.net to get a copy of this message | ||
ID: 11903
Comment by: sex-amateur1838 at hotmail dot com
Reported By: peter at wingercom dot net
Status: Bogus
Bug Type: DOM XML related
Operating System: FreeBSD 4.3
PHP Version: 4.0.6
New Comment:
<a href=http://best-secretladiesse.da.ru>amateur
sex</a>
Previous Comments:
------------------------------------------------------------------------
[2001-11-29 07:42:26] mfischer@php.net
This is because title actually *IS* in the namespace. This is how XML
and namespace works.
I suggest further reading on
http://www.w3.org/TR/REC-xml-names/
and
http://www.w3.org/TR/xpath#function-local-name
In you're case I'ld use "//*[local-name() = 'title']" instead of
"//title"
(thanks to Daniel Veillard pointing this out)
Bogus (not a PHP bug).
PS: thnx anyway, found a segfault in xpath_eval_expression :)
------------------------------------------------------------------------
[2001-07-06 04:44:06] peter at wingercom dot net
I forgot again....
libxml version: 2.3.10
iconv version: 2.0
------------------------------------------------------------------------
[2001-07-05 08:51:13] peter at wingercom dot net
I forgot.
This namespace decleration will also work with xpath_eval
<html xmlns:thisworks="http://www.w3.org/1999/xhtml">
------------------------------------------------------------------------
[2001-07-05 08:44:09] peter at wingercom dot net
Hi, When using default namespace in the XML (XHTML) source
xpath_eval will not return any result except with the request "//*"
whereby it will return the whole XML source.
When making another namespace than "xmlns" everything works fine.
// The xpaht_eval() will NOT work with this line
$xhtml = '<html
xmlns="http://www.w3.org/1999/xhtml"><head><title>hummmm......</title></head><body></body></html>';
// The xpaht_eval() will work with this line
$xhtml = '<html
BUGxmlns="http://www.w3.org/1999/xhtml"><head><title>hummmm......</title></head><body></body></html>';
$doc = xmldoc($xhtml);
$ctx = xpath_new_context($doc);
$node = xpath_eval_expression($ctx,"//title");
var_dump($node->nodeset);
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=11903&edit=1