php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36574 getElementById can`t "see" ID in html-tag <input>
Submitted: 2006-03-01 16:07 UTC Modified: 2006-03-01 22:25 UTC
From: taymir at gmail dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.1.2 OS: Windows XP pro
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: taymir at gmail dot com
New email:
PHP Version: OS:

 

 [2006-03-01 16:07 UTC] taymir at gmail dot com
Description:
------------
I use DOMDocument::loadHTML(...) method to create DOM-tree from html-document. I want to modify some attributes of such tags as form, select, option, input. The code works as it should for all tags except <input ...>. I can't get input-element by ID.

Reproduce code:
---------------
<?php
$text = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><input id="test">';
$xml = new DOMDocument(1.0);
$xml->loadHTML($text);
var_dump($xml->getElementByID('test'));
?>

Expected result:
----------------
object(DOMElement)#2 (0) { }

Actual result:
--------------
NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-01 19:17 UTC] bjori@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

DOMDocument->validateOnParse = true;
DOMDocument->load....
-- OR --
DOMDocument->validate()
DOMDocument->getElementById()
 [2006-03-01 22:14 UTC] taymir at gmail dot com
Here is more accurate example: http://pastebin.com/579031

The result is:
1) form: object(DOMElement)#2 (0) { }
2) input: NULL
3) input: NULL 

As you can see, I`ve used validateOnParse property. getElementById()-method works fine (even without validation) with any html-tag (well, at least with those I`ve tested) except input.
 [2006-03-01 22:25 UTC] rrichards@php.net
Before this gets re-opened, as its still bogus. Its a libxml2 bug being taken care of there.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 09:01:35 2025 UTC