#26926 [Opn]: DOMXML LoadHTML throws exception on URL with "&"
| From: | vania at pandorasdream dot com | Date: | Thu, 15 Jan 2004 21:02:12 +0000 |
| Subject: | #26926 [Opn]: DOMXML LoadHTML throws exception on URL with "&" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-53400@lists.php.net to get a copy of this message | ||
ID: 26926
User updated by: vania at pandorasdream dot com
Reported By: vania at pandorasdream dot com
Status: Open
Bug Type: DOM XML related
Operating System: Windows XP
PHP Version: 5.0.0b3 (beta3)
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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