#26926 [Opn->Fbk]: DOMXML LoadHTML throws exception on URL with "&"
| From: | rrichards@php.net | Date: | Thu, 15 Jan 2004 22:21:00 +0000 |
| Subject: | #26926 [Opn->Fbk]: DOMXML LoadHTML throws exception on URL with "&" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-53402@lists.php.net to get a copy of this message | ||
ID: 26926
Updated by: rrichards@php.net
Reported By: vania at pandorasdream dot com
-Status: Open
+Status: Feedback
Bug Type: DOM XML related
Operating System: Windows XP
PHP Version: 5.0.0b3 (beta3)
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
If you encounter the error with a current snap, can you provide the
results of:
<?php
var_dump(stream_get_wrappers());
?>
Previous Comments:
------------------------------------------------------------------------
[2004-01-15 16:02:12] vania at pandorasdream dot com
Sorry... Wrong copy/paste for the actual result...
ERROR [2]domdocument::loadHTMLFile() [<a
href='function.loadHTMLFile'>function.loadHTMLFile</a>]:
htmlParseEntityRef: expecting ';' in http://www.php.net/, line: 118.
PHP 5.0.0RC1-dev (WINNT). at line 5
------------------------------------------------------------------------
[2004-01-15 15:57:49] vania at pandorasdream dot com
Description:
------------
Using the example for LoadHTML the www.php.net site contains a URL with
an ampersand (line 118 <a
href="http://cvs.php.net/diff.php/php-src/NEWS?login=2&r1=1.1247.2.452&r2=1.1247.2.522">NEWS</a>
file.). The error says it is looking for a missing ";", apparently
thinking it should be an entity.
When I remove the try/catch, no errors occur, but nothing gets printed.
Using a different URL to a file without the & works correctly.
Reproduce code:
---------------
<?php
try
{
$dom = new domdocument;
@$dom->loadHTMLFile("http://www.php.net/");
$xp = new domxpath($dom);
$result = $xp->query("/html/head/title");
print $result[0]->firstChild->data;
}
catch (exception $exc)
{
print $exc->getMessage()." at line ".$exc->getLine();
}
?>
Expected result:
----------------
PHP: Hypertext Preprocessor
Actual result:
--------------
<?php
try
{
$dom = new domdocument;
@$dom->loadHTMLFile("http://www.php.net/");
$xp = new domxpath($dom);
$result = $xp->query("/html/head/title");
print $result[0]->firstChild->data;
}
catch (exception $exc)
{
print $exc->getMessage()." at line ".$exc->getLine();
}
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26926&edit=1