|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-06-09 05:35 UTC] 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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 11:00:02 2025 UTC |
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)