note 76512 deleted from ref.simplexml by danbrown
| From: | danbrown@php.net | Date: | Mon, 18 May 2009 01:20:17 +0000 |
| Subject: | note 76512 deleted from ref.simplexml by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155520@lists.php.net to get a copy of this message | ||
Note Submitter: bens at effortlessis dot com
----
Data can be lost when using SimpleXML!!! Consider the following XML:
<root position="base">
<edition id="20070705" onsale="2007-07-06" online="2007-07-06
09:00">
<headline maxchars="50" someattr="whatever">
<cell attr="meaningless">The new issue</cell>
</headline>
</edition>
<monkey id="123">
<face class="round">red</face>
<face class="square">pink</face>
</monkey>
</root>
parsed as follows
$res = simplexml_load_string($xml);
print_r($res);
1) The name of the first (root?) tag of the document is lost - there is no way to find out what the
root tag was called. (in this case, I called it "root") However, the attributes within
that tag are preserved. (position="base")
2) The innermost tag's attributes are lost. (apparently, any tag with data in it) Note that
attr='meaningless' in the cell tag, as well as the
class="square"/"round" is lost.
This is when using PHP 5.1.6 on Fedora Core 6 with stock RPMs.