|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-07-26 12:06 UTC] bugz at nagash dot org
Description:
------------
result is unexpected
Reproduce code:
---------------
$doc = new DOMDocument("1.0");
$root = $doc->createElement("HTML");
$root = $doc->appendChild($root);
$head = $doc->createElement("HEAD");
$head = $root->appendChild($head);
$title = $doc->createElement("TITLE");
$title = $head->appendChild($title);
$text = $doc->createTextNode("This is the title");
$text = $title->appendChild($text);
echo $doc->saveXML();
Expected result:
----------------
<?xml version="1.0"?>
<HTML>
<HEAD>
<TITLE>
This is the title
</TITLE>
</HEAD>
</HTML>
Actual result:
--------------
<?xml version="1.0"?>
<HTML />
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 01:00:01 2025 UTC |
Done. Still using latest PHP-CLI from PHP5.1 snapshot under Win2k - sorry, no XP or any other Win32 system around here. The code: ----- <? var_dump($doc = new DOMDocument("1.0")); echo $doc->saveXML(); var_dump($root = $doc->createElement("HTML")); echo $doc->saveXML(); var_dump($root = $doc->appendChild($root)); echo $doc->saveXML(); var_dump($head = $doc->createElement("HEAD")); echo $doc->saveXML(); var_dump($head = $root->appendChild($head)); echo $doc->saveXML(); var_dump($title = $doc->createElement("TITLE")); echo $doc->saveXML(); var_dump($title = $head->appendChild($title)); echo $doc->saveXML(); var_dump($text = $doc->createTextNode("This is the title")); echo $doc->saveXML(); var_dump($text = $title->appendChild($text)); echo $doc->saveXML(); ?> ----- The output: ----- object(DOMDocument)#2 (0) { } <?xml version="1.0"?> object(DOMElement)#3 (0) { } <?xml version="1.0"?> object(DOMElement)#3 (0) { } <?xml version="1.0"?> <HTML/> object(DOMElement)#4 (0) { } <?xml version="1.0"?> <HTML/> object(DOMElement)#4 (0) { } <?xml version="1.0"?> <HTML/> object(DOMElement)#5 (0) { } <?xml version="1.0"?> <HTML/> object(DOMElement)#5 (0) { } <?xml version="1.0"?> <HTML/> object(DOMText)#6 (0) { } <?xml version="1.0"?> <HTML/> object(DOMText)#6 (0) { } <?xml version="1.0"?> <HTML/> ----- The same code under Linux outputs this: ----- object(DOMDocument)#1 (0) { } <?xml version="1.0"?> object(DOMElement)#2 (0) { } <?xml version="1.0"?> object(DOMElement)#2 (0) { } <?xml version="1.0"?> <HTML/> object(DOMElement)#3 (0) { } <?xml version="1.0"?> <HTML/> object(DOMElement)#3 (0) { } <?xml version="1.0"?> <HTML><HEAD/></HTML> object(DOMElement)#4 (0) { } <?xml version="1.0"?> <HTML><HEAD/></HTML> object(DOMElement)#4 (0) { } <?xml version="1.0"?> <HTML><HEAD><TITLE/></HEAD></HTML> object(DOMText)#5 (0) { } <?xml version="1.0"?> <HTML><HEAD><TITLE/></HEAD></HTML> object(DOMText)#5 (0) { } <?xml version="1.0"?> <HTML><HEAD><TITLE>This is the title</TITLE></HEAD></HTML> ----- I could try it with Win32 debug build too, if you tell me where I can get it.Yep, it was On. Turning it Off solves the problem. With compatibility On and error_reporting E_ALL|E_STRICT the code outputs: -- Strict Standards: Implicit cloning object of class 'DOMDocument' because of 'zend.ze1_compatibility_mode' in E:\ftp\dom.test object(DOMDocument)#2 (0) { } <?xml version="1.0"?> Strict Standards: Implicit cloning object of class 'DOMElement' because of 'zend.ze1_compatibility_mode' in E:\ftp\dom.test. object(DOMElement)#3 (0) { } <?xml version="1.0"?> Strict Standards: Implicit cloning object of class 'DOMElement' because of 'zend.ze1_compatibility_mode' in E:\ftp\dom.test. object(DOMElement)#3 (0) { } <?xml version="1.0"?> <HTML/> Strict Standards: Implicit cloning object of class 'DOMElement' because of 'zend.ze1_compatibility_mode' in E:\ftp\dom.test. object(DOMElement)#4 (0) { } <?xml version="1.0"?> <HTML/> Strict Standards: Implicit cloning object of class 'DOMElement' because of 'zend.ze1_compatibility_mode' in E:\ftp\dom.test. object(DOMElement)#4 (0) { } <?xml version="1.0"?> <HTML/> Strict Standards: Implicit cloning object of class 'DOMElement' because of 'zend.ze1_compatibility_mode' in E:\ftp\dom.test. object(DOMElement)#5 (0) { } <?xml version="1.0"?> <HTML/> Strict Standards: Implicit cloning object of class 'DOMElement' because of 'zend.ze1_compatibility_mode' in E:\ftp\dom.test. object(DOMElement)#5 (0) { } <?xml version="1.0"?> <HTML/> Strict Standards: Implicit cloning object of class 'DOMText' because of 'zend.ze1_compatibility_mode' in E:\ftp\dom.test.php object(DOMText)#6 (0) { } <?xml version="1.0"?> <HTML/> --