|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
29 - 13 = ?
Subscribe to this entry?

 [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-2023 The PHP Group
All rights reserved.
Last updated: Sun May 28 11:03:41 2023 UTC