ID: 48502 Updated by: chr...@php.net Reported By: trex6 at mail dot ru -Status: Bogus +Status: Open Bug Type: DOM XML related Operating System: GNU/Linux PHP Version: 5.2.9 New Comment:
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. If I make a complete script out of your snippet like *** <?php $dom = new domdocument(); $dom->loadXML("<foo/>"); $ParentElement = $dom->documentElement; $imgPic = new DOMElement("img"); $ParentElement->appendChild($imgPic); $imgPic->setAttribute("src","./1.jpg"); print $dom->saveXML(); *** I get <?xml version="1.0"?> <foo><img src="./1.jpg"/></foo> which looks perfectly fine to me. So please send a complete, reproducable script. And: You should use domdocument->createElement() and not new domelement (but doesn't seem to be the root of the problem) Previous Comments: ------------------------------------------------------------------------ [2009-06-09 05:58:08] ras...@php.net If you use saveXML() it does. If you use saveHTML(), it doesn't because that is how it is supposed to be in HTML. If you want XHTML, use saveXML() ------------------------------------------------------------------------ [2009-06-09 05:35:39] trex6 at mail dot ru Description: ------------ I want add img element to my xml document. Reproduce code: --------------- $imgPic = new DOMElement("img"); $ParentElement->appendChild($imgPic); $imgPic->setAttribute("src","./1.jpg"); Expected result: ---------------- <img src="./1.jpg" /> Actual result: -------------- <img src="./1.jpg"> Script doesn`t generate closled '/' for tag img. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48502&edit=1