php.net |  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:
MUST BE VALID
Solve the problem:
30 + 10 = ?
Subscribe to this entry?

 
 [2006-08-31 14:59 UTC] 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>



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-31 17:06 UTC] chregu@php.net
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: Thu Mar 28 16:01:29 2024 UTC