Bug #16647 Updated: DomDocument->get_element_by_id() doesn't work
| From: | chregu@php.net | Date: | Thu, 18 Apr 2002 11:38:25 +0000 |
| Subject: | Bug #16647 Updated: DomDocument->get_element_by_id() doesn't work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-5282@lists.php.net to get a copy of this message | ||
ID: 16647
Updated by: chregu@php.net
Reported By: s.li@gmx.de
Status: Analyzed
Bug Type: DOM XML related
Operating System: linux 2.4.4
PHP Version: 4.0CVS-2002-04-1
Previous Comments:
------------------------------------------------------------------------
[2002-04-18 01:37:04] steinm@php.net
get_element_by_id() used xpath_eval as well but
searches for "//*[@ID = '%s']". If you capitalize
the id it should work. Do you have an idea how to search
case insensitve?
------------------------------------------------------------------------
[2002-04-16 20:04:48] s.li@gmx.de
The following script returns bool(false):
<?php
$src = <<< _END
<html>
<head><title> Test </title></head>
<body>
<h1>Test</h1>
<span id="test">Foo</span>
</body>
</html>
_END;
$doc = domxml_open_mem($src);
$n = $doc->get_element_by_id("test");
var_dump($n);
?>
Workaround: Use Xpath expressions to find the node:
<?php
$src = <<< _END
<html>
<head><title> Test </title></head>
<body>
<h1>Test</h1>
<span id="test">Foo</span>
</body>
</html>
_END;
$doc = domxml_open_mem($src);
$ctx = $doc->xpath_new_context();
$res = $ctx->xpath_eval("//*[@id='test']");
$n = $res->nodeset[0];
var_dump($n);
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16647&edit=1