#38672 [Opn->Bgs]: asXML outputs elements added with addChild() on the same line

From: Date: Thu, 31 Aug 2006 17:06:42 +0000
Subject: #38672 [Opn->Bgs]: asXML outputs elements added with addChild() on the same line
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-101578@lists.php.net to get a copy of this message
ID: 38672 Updated by: chregu@php.net Reported By: stefano dot comarin at primeur dot com -Status: Open +Status: Bogus Bug Type: SimpleXML related Operating System: Windows 2000 PHP Version: 5.1.6 New Comment: That's expected behaviour. The xml extension do not add whitespaces just to make the XML look nice Previous Comments: ------------------------------------------------------------------------ [2006-08-31 14:59:40] stefano dot comarin at primeur dot com Description: ------------ If you add elements with addChild() and then call asXML() the added elements are printed on the same line. This makes the XML difficult to read. Reproduce code: --------------- <?php $xmlstr = <<<XML <a> <b>bbb</b> </a> XML; $xml = new SimpleXMLElement($xmlstr); $xml->addChild('c', 'ccc'); $xml->addChild('d', 'ddd'); echo $xml->asXML(); ?> Expected result: ---------------- <?xml version="1.0"?> <a> <b>bbb</b> <c>ccc</c> <d>ddd</d> </a> Actual result: -------------- <?xml version="1.0"?> <a> <b>bbb</b> <c>ccc</c><d>ddd</d></a> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38672&edit=1

« previous php.bugs (#101578) next »