|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-06-08 15:28 UTC] rrichards@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Fri Apr 03 18:00:01 2026 UTC |
Description: ------------ When a tag created with DOMDocument->createElement() is given *no* value, its generated output (using DOMDocument->saveXML()) is a shortened (self-closing) tag, but when it is given an *empty* value such as a blank string or NULL, it displays as an expanded (opening and closing) tag. Shouldn't any empty value be treated the same? If anyone really wanted expanded tags, they could use the already implemented LIBXML_NOEMPTYTAG option, but there is no equivalent option to ask for shortened tags. Reproduce code: --------------- $doc1 = new DOMDocument(); $root1 = $doc1->createElement('root'); $doc1->appendChild($root1); printf( "doc1: %s\n", $doc1->saveXML() ); $doc2 = new DOMDocument(); $root2 = $doc2->createElement('root', ''); $doc2->appendChild($root2); printf( "doc2: %s\n", $doc2->saveXML() ); $doc3 = new DOMDocument(); $root3 = $doc3->createElement('root', NULL); $doc3->appendChild($root3); printf( "doc3: %s\n", $doc3->saveXML() ); Expected result: ---------------- doc1: <?xml version="1.0"?><root/> doc2: <?xml version="1.0"?><root/> doc3: <?xml version="1.0"?><root/> Actual result: -------------- doc1: <?xml version="1.0"?><root/> doc2: <?xml version="1.0"?><root></root> doc3: <?xml version="1.0"?><root></root>