Bug #46672 [Asn->Wfx]: Cloned SimpleXML Output Different
| From: | rrichards@php.net | Date: | Thu, 27 May 2010 09:09:33 +0000 |
| Subject: | Bug #46672 [Asn->Wfx]: Cloned SimpleXML Output Different | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-150868@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=46672&edit=1
ID: 46672
Updated by: rrichards@php.net
Reported by: rfludwick at gmail dot com
Summary: Cloned SimpleXML Output Different
-Status: Assigned
+Status: Wont fix
Type: Bug
Package: SimpleXML related
Operating System: *
PHP Version: 5.*, 6CVS (2009-04-01)
Assigned To: rrichards
New Comment:
The asXML() method is special in regards to the document element as it
treats it
as a document node for simple trees. A clone of a document element is a
regular
element (a document can only have 1) and does not get special
treatment.
Patch breaks in memory tree. Either manually add the XML declaration to
the clone
or import to dom and clone the document and work off the new document.
Previous Comments:
------------------------------------------------------------------------
[2010-05-27 08:10:57] mike@php.net
Rob, could you have a look at this tiny patch?
------------------------------------------------------------------------
[2010-04-05 03:51:11] compuart dot php at gmail dot com
The issue appears to be the cloned node doesn't have a document pointer
as its ultimate parent. Attached patch should fix that.
------------------------------------------------------------------------
[2008-12-30 14:49:29] rfludwick at gmail dot com
I got the same result when using the snapshot, as well as version 5.2.8.
------------------------------------------------------------------------
[2008-11-25 23:35:36] rfludwick at gmail dot com
Description:
------------
It appears that cloning a SimpleXML object will not produce the same XML
output on asXML() as the original object. The original will output the
XML header and a line break after the XML while the cloned object is
missing these.
Reproduce code:
---------------
<?php
$simplexml = new SimpleXMLElement("<root />");
$simplexml->path->to->node = "Zend";
$simplexml_2 = clone $simplexml;
echo "|{$simplexml->asXML()}|\n|{$simplexml_2->asXML()}|";
Expected result:
----------------
|<?xml version="1.0"?>
<root><path><to><node>Zend</node></to></path></root>
|
|<?xml version="1.0"?>
<root><path><to><node>Zend</node></to></path></root>
|
Actual result:
--------------
|<?xml version="1.0"?>
<root><path><to><node>Zend</node></to></path></root>
|
|<root><path><to><node>Zend</node></to></path></root>|
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=46672&edit=1