| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 15:00:01 2025 UTC | 
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); }<?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).