|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38672 asXML outputs elements added with addChild() on the same line
Submitted: 2006-08-31 14:59 UTC Modified: 2006-08-31 17:06 UTC
From: stefano dot comarin at primeur dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.1.6 OS: Windows 2000
Private report: No CVE-ID: None
 [2006-08-31 14:59 UTC] stefano dot comarin at primeur dot com
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:
        $xmlstr = <<<XML
        $xml = new SimpleXMLElement($xmlstr);
        $xml->addChild('c', 'ccc');
        $xml->addChild('d', 'ddd');
        echo $xml->asXML();

Expected result:
<?xml version="1.0"?>

Actual result:
<?xml version="1.0"?>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-31 17:06 UTC]
That's expected behaviour. The xml extension do not add whitespaces just to make the XML look nice
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 22:01:31 2024 UTC