note 81612 added to function.simplexml-import-dom
| From: | peter-SPAMrubbish-ATveridon dot com at osu1 dot php dot net | Date: | Thu, 06 Mar 2008 07:06:44 +0000 |
| Subject: | note 81612 added to function.simplexml-import-dom | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136782@lists.php.net to get a copy of this message | ||
Something that surprised me, any changes made to the SimpleXML object obtained from the imported
DOMDocument also change the original DOMDocument.
e.g.
<?php
$string = '<root><foo>abc</foo></root>';
$domxml = DOMDocument::loadXML($string);
$simplexml = simplexml_import_dom($domxml);
$simplexml->foo = "xyz";
$simplexml->bar = "123";
echo $domxml->saveXML();
?>
Outputs:
--START--
<?xml version="1.0"?>
<root><foo>xyz</foo><bar>123</bar></root>
----
Server IP: 64.71.164.2
Probable Submitter: 59.167.146.189
----
Manual Page -- http://www.php.net/manual/en/function.simplexml-import-dom.php
Edit -- https://master.php.net/note/edit/81612
Del: integrated -- https://master.php.net/note/delete/81612/integrated
Del: useless -- https://master.php.net/note/delete/81612/useless
Del: bad code -- https://master.php.net/note/delete/81612/bad+code
Del: spam -- https://master.php.net/note/delete/81612/spam
Del: non-english -- https://master.php.net/note/delete/81612/non-english
Del: in docs -- https://master.php.net/note/delete/81612/in+docs
Del: other reasons-- https://master.php.net/note/delete/81612
Reject -- https://master.php.net/note/reject/81612
Search -- https://master.php.net/manage/user-notes.php