ID:               37957
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jfowlie at navarik dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         DOM XML related
 Operating System: Linux
 PHP Version:      5.1.4
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

Can't reproduce.


Previous Comments:
------------------------------------------------------------------------

[2006-06-29 06:16:51] jfowlie at navarik dot com

Description:
------------
I was attempting to update the content of some anchor elements by
setting the nodeValue. It doesn't seem to matter how high I set the
max_execution_time limit, if there is a   entity in the nodeValue,
PHP just hangs until it times out. (It works just fine with &
though...)


Reproduce code:
---------------
<?php
$xhtml = <<<XHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title>Untitled</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
</head>
<body>
<a href="#" id="id-goes-here">Link 1</a>
<a href="#" id="id-2-goes-here">Link 2 &amp;</a>
<a href="#" id="id-3-goes-here">Link 3 &nbsp;</a>
</body>
</html>
XHTML;


$dom = new DOMDocument('1.0','iso-8859-1');

// I tried it with this set to true or false
//$xml->preserveWhiteSpace = FALSE;

// You need this, otherwise the nbsp entity is not valid
$dom->resolveExternals = TRUE;

$dom->loadXML($xhtml);

$bookmarks = $dom->getElementsByTagName('a');

$count = 0;

foreach($bookmarks as $bookmark_node){
        ++$count;
        $id_value = $bookmark_node->getAttribute('id');
        print "Id value: ".$id_value."<br />";
        print "Node value: ".$bookmark_node->nodeValue."<br />";
        print "Setting nodeValue to 'test$count'<br />";
        $bookmark_node->nodeValue = 'test'.$count;
        print "Node value has been set!
({$bookmark_node->nodeValue})<hr />";
}
?>


Expected result:
----------------
Id value: id-goes-here
Node value: Link 1
Setting nodeValue to 'test1'
Node value has been set! (test1)

Id value: id-2-goes-here
Node value: Link 2 &
Setting nodeValue to 'test2'
Node value has been set! (test2)

Id value: id-3-goes-here
Node value: Link 3
Setting nodeValue to 'test3'
Node value has been set! (test3)


Actual result:
--------------
Id value: id-goes-here
Node value: Link 1
Setting nodeValue to 'test1'
Node value has been set! (test1)

Id value: id-2-goes-here
Node value: Link 2 &
Setting nodeValue to 'test2'
Node value has been set! (test2)

Id value: id-3-goes-here
Node value: Link 3
Setting nodeValue to 'test3'

Fatal error: Maximum execution time of 30 seconds exceeded in
nbsp-dom-test.php on line 39



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=37957&edit=1

Reply via email to