php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26813 getElementById doesn't return anything
Submitted: 2004-01-06 08:32 UTC Modified: 2004-01-07 11:36 UTC
From: msw at seebi dot de Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.0.0b3 (beta3) OS: windows xp prof
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: msw at seebi dot de
New email:
PHP Version: OS:

 

 [2004-01-06 08:32 UTC] msw at seebi dot de
Description:
------------
I'v used getElementById() to touch an element. It seems to me that getElementById() doesn't return anything. 

Reproduce code:
---------------
<?php
$dom = new domdocument;
$t=$dom->load(dirname(__FILE__)."/news.xml");
if(!$dom) {
  echo "Error while parsing the document\n";
  exit;
}

$node=$dom->getElementById("486");
print ($node);
print("<br>".$node->nodeName);
?>

XML:

<?xml version="1.0" encoding="iso-8859-1"?>
<newsliste>
<news id="486" rubrik='xsl-fo' site="javaxml">
 <datum>14.08.2003</datum>
 <headline>Kleines Update von XEP</headline>
 <text>blablablabla</text>
 <Links>
  <Web-Adresse xml:link='simple' href='http://xep.xattic.com/'>
   <text>XEP 3.5.4</text>
  </Web-Adresse>
 </Links>
</news>
</newsliste>



Expected result:
----------------
The PHP code should print out the node name (news)

Actual result:
--------------
nothing

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-06 12:51 UTC] rrichards@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

DTD required to use id
 [2004-01-07 03:08 UTC] msw at seebi dot de
Thats not the correct behaviour according to W3C. I know this behaviour because it is also used in PHP 4.x. You should fix this to get more compatability with DOM. getElementById() should work without DTD.
 [2004-01-07 06:31 UTC] rrichards@php.net
Re-read the specs (this is the same as in Level 2 specs)
http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-getElBId
'Note: Attributes with the name "ID" or "id" are not of type ID unless so defined.'
 [2004-01-07 11:36 UTC] msw at seebi dot de
You are right, I didn't read the note in the specs. Sorry for my reply.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Nov 23 20:01:23 2020 UTC