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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 17:01:30 2024 UTC