|  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
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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-2023 The PHP Group
All rights reserved.
Last updated: Sun Sep 24 17:01:24 2023 UTC