#47833 [Opn->Fbk]: xpath::query fails when huge xml file loaded
ID: 47833
Updated by: jani@php.net
Reported By: getmequick at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: DOM XML related
Operating System: Windows XP
PHP Version: 5.2.9
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
Previous Comments:
------------------------------------------------------------------------
[2009-03-29 20:41:54] getmequick at gmail dot com
Description:
------------
I'm running latest PHP 5.2.9.1 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)
summary:
- 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:
---------------
test.xml
------------------
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<url>
<loc>..</loc>
</url>
<url>
<loc>..</loc>
</url>
<url>
<loc>..</loc>
</url>
</urlset>
test.php
------------------
<?php
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");
var_dump($locUrls);
?>
Expected result:
----------------
Nodelist object.
Actual result:
--------------
PHP timeout error.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47833&edit=1
Thread (2 messages)