ID: 16647 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Analyzed Bug Type: DOM XML related Operating System: linux 2.4.4 PHP Version: 4.0CVS-2002-04-1 New Comment:
Quote from the Document Object Model (DOM) Level 2 Core Specification: Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return null. That means that DomDocument->get_document_by_id("X") and XPathContext->xpath_eval("//*[@id='X']) are not equivalent and that the former function should only return a result if a DTD is referenced which declares attributes of type ID. Previous Comments: ------------------------------------------------------------------------ [2002-04-18 07:44:04] [EMAIL PROTECTED] Ooop. didn't much think about case sensitivity back then :) A quick soultion would be: "//*[@ID = '%s' or @id = '%s']". I don't know, which version is really correct according to W3C (but anyways, the ID-attribute should be stated in the DTD, so this whole xpath-approach is actually rather wrong :) ) chregu ------------------------------------------------------------------------ [2002-04-18 01:37:04] [EMAIL PROTECTED] 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] [EMAIL PROTECTED] 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