php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45666 getElementsByTagName returns NULL
Submitted: 2008-07-31 14:25 UTC Modified: 2008-08-08 01:00 UTC
Votes:6
Avg. Score:4.0 ± 0.8
Reproduced:5 of 5 (100.0%)
Same Version:3 (60.0%)
Same OS:1 (20.0%)
From: matthias dot sojka at gmail dot com Assigned:
Status: No Feedback Package: DOM XML related
PHP Version: 5.2.6 OS: Linux Slackware 12
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
4 + 39 = ?
Subscribe to this entry?

 
 [2008-07-31 14:25 UTC] matthias dot sojka at gmail dot com
Description:
------------
I don't understand why, but on PHP 5.2.6 oDom->getElementsByTagName() delivers NULL. I didn't have that problem with 5.2.5. Our framework is working fine on our PHP 5.2.5 Machines and my local MAMP.

Reproduce code:
---------------
if (($sFirstChar !== 'i') && ($sFirstChar !== 'b') && ($sFirstChar !== 'f')) {
				$oChild = $this->_oDom->createElement($this->_prepareKeyName(true, $sName));
@				$oChild->appendChild($this->_oDom->createCDATASection($mValue));
@				$this->_oDom->documentElement->replaceChild($oChild, $oElement);
			}

Expected result:
----------------
An instance of DOM-Document should be returned.

Actual result:
--------------
NULL returned.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-31 14:30 UTC] matthias dot sojka at gmail dot com
Code wasn't complete. I'm sorry for this.

$oElement   = $this->_oDom->getElementsByTagName($this->_prepareKeyName(true, $sName))->item(0);
$sFirstChar = $sName{0};
			
			
if (($sFirstChar !== 'i') && ($sFirstChar !== 'b') && ($sFirstChar !== 'f')) {
	$oChild = $this->_oDom->createElement($this->_prepareKeyName(true, $sName));
$oChild->appendChild($this->_oDom->createCDATASection($mValue));
$this->_oDom->documentElement->replaceChild($oChild, $oElement);
			}
 [2008-07-31 15:48 UTC] rrichards@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2008-08-08 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-10-20 15:47 UTC] gustavo dot a dot herrera at gmail dot com
<?php
//PHP Version 5.2.6

$source = '<algo>text here</algo>';
$xml = new DOMDocument();
$xml->loadXML($source);
echo $xml->saveXML();
$algo = $xml->getElementsByTagName('algo');
var_dump($algo);
?>
//The final var_dump dumps an empty object, not the node, but the node exists (you can see it in the saveXML result).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC