note 76512 added to ref.simplexml

From: Date: Wed, 18 Jul 2007 20:58:37 +0000
Subject: note 76512 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-128700@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.197 Probable Submitter: 76.193.72.245 ---- Manual Page -- http://www.php.net/manual/en/ref.simplexml.php Edit -- https://master.php.net/note/edit/76512 Del: integrated -- https://master.php.net/note/delete/76512/integrated Del: useless -- https://master.php.net/note/delete/76512/useless Del: bad code -- https://master.php.net/note/delete/76512/bad+code Del: spam -- https://master.php.net/note/delete/76512/spam Del: non-english -- https://master.php.net/note/delete/76512/non-english Del: in docs -- https://master.php.net/note/delete/76512/in+docs Del: other reasons-- https://master.php.net/note/delete/76512 Reject -- https://master.php.net/note/reject/76512 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128700) next »