|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52661 lookupNamespaceURI returns nothing
Submitted: 2010-08-20 20:07 UTC Modified: 2013-02-18 00:34 UTC
From: tim at buyplaytix dot com Assigned:
Status: No Feedback Package: DOM XML related
PHP Version: 5.3.3 OS: Ubuntu maverick
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: tim at buyplaytix dot com
New email:
PHP Version: OS:


 [2010-08-20 20:07 UTC] tim at buyplaytix dot com
Hopefully this is something that's fairly easy to see in the code. Providing a 
full working code sample will be somewhat difficult. This seems to happen most 
frequently with nodes that have been removed from the dom and added back 

Basically if I call lookupNamespace on a node I'm getting nothing back. If I load 
the node into SimpleXML and call getNamespaces I'm getting the namespace as 

The attached code is a workaround for the problem.

Test script:
  private function get_namespace($node) {
        $node_namespace = $node->lookupNamespaceURI($node->prefix);
        if($node instanceof DomElement && $node_namespace == null && strpos($node->nodeName, ":") !== false) {
            // must be some sort of DOM bug. Look and see if we can figure it out from simplexml
            $sxe = simplexml_import_dom($node);
            $namespaces = $sxe->getNamespaces();
            foreach($namespaces as $prefix => $namespace) {
                if(strpos($node->nodeName, $prefix . ":") == 0) {
                    $node_namespace = $namespace;
        return $nodeNamespace;

Expected result:
I expect that if I get into the body of the if statement that I will return a 
null $node_namespace. Preferably I'd never get into the if statement.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-20 21:24 UTC]
-Status: Open +Status: Feedback
 [2010-08-20 21:24 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

most likely its due to how you are removing and adding them back in. Need a 
reproducible script to determine if this is really a bug in DOM or not
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 12:01:28 2024 UTC