|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47833 xpath::query fails when huge xml file loaded
Submitted: 2009-03-29 20:41 UTC Modified: 2009-04-21 01:00 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: getmequick at gmail dot com Assigned:
Status: No Feedback Package: DOM XML related
PHP Version: 5.2.9 OS: Windows XP
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: getmequick at gmail dot com
New email:
PHP Version: OS:


 [2009-03-29 20:41 UTC] getmequick at gmail dot com
I'm running latest PHP on Win XP machine with apache 2.0 on it

I have 1GB free RAM (of 2GB)

here's the issue, I load huge xml file (8MB) that has namespace defined in it and try query with xpath, it ends with timeout error

strangely, when I move namespace definition out, it works. 
also, if I reduce filesize to say 1KB it also works (with namespace defined)


- Doesn't work when xml has a namespace defined and filesize is huge (~8MB tested)

- Works when filesize is tiny and has a namespace.
- Works when filesize is huge and no namespace defined.

Reproduce code:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="">

ini_set('display_errors', true);
ini_set('error_reporting', E_ALL);

$dom     = DomDocument::load('test.xml');
$xpath   = new DomXPath($dom);
$ns    = '';
if ($dom->documentElement && $dom->documentElement->namespaceURI)
  $xpath->registerNamespace('ns', $dom->documentElement->namespaceURI);
  $ns    = 'ns:';

$locUrls  = $xpath->query("//{$ns}loc");

Expected result:
Nodelist object.

Actual result:
PHP timeout error.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-13 18:27 UTC]
Please try using this CVS snapshot:
For Windows:

 [2009-04-21 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 13:01:27 2024 UTC