|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11903 xpath_eval does not work with default namespace.
Submitted: 2001-07-05 08:44 UTC Modified: 2001-11-29 07:42 UTC
From: peter at wingercom dot net Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 4.0.6 OS: FreeBSD 4.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: peter at wingercom dot net
New email:
PHP Version: OS:


 [2001-07-05 08:44 UTC] 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=""><head><title>hummmm......</title></head><body></body></html>';
    // The xpaht_eval() will work with this line
    $xhtml = '<html BUGxmlns=""><head><title>hummmm......</title></head><body></body></html>';
    $doc = xmldoc($xhtml);
    $ctx = xpath_new_context($doc); 
    $node = xpath_eval_expression($ctx,"//title");


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-05 08:51 UTC] peter at wingercom dot net
I forgot.

This namespace decleration will also work with xpath_eval
<html xmlns:thisworks="">
 [2001-07-06 04:44 UTC] peter at wingercom dot net
I forgot again....

libxml version: 2.3.10
iconv version: 2.0
 [2001-11-29 07:42 UTC]
This is because title actually *IS* in the namespace. This is how XML and namespace works.

I suggest further reading on

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 :)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 08:02:42 2024 UTC