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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: stefano dot comarin at primeur dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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 Dec 26 13:01:30 2024 UTC