#46137 [Com]: Attributes not loading

From: Date: Sun, 21 Sep 2008 15:11:14 +0000
Subject: #46137 [Com]: Attributes not loading
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-129153@lists.php.net to get a copy of this message
ID: 46137 Comment by: phpwnd at gmail dot com Reported By: regsuy at yahoo dot com Status: Open Bug Type: SimpleXML related Operating System: windows, linux PHP Version: 5.2.6 New Comment: There might be a misunderstanding here. First of all, there is no "$xml array", $xml is a SimpleXMLElement object. Secondly, SimpleXML does a fair amount of magic behind the scene (to make your life easier :)), and functions such as print_r() or var_dump() cannot display a complete, or accurate, representation of the node you're trying to inspect. If you really want to know the inside of a node, use asXML() instead. In short, this is not a bug. Those attributes do exist and you can access them normally. print_r() simplay lacks the means, and semantics, to display XML them. Previous Comments: ------------------------------------------------------------------------ [2008-09-20 11:50:40] regsuy at yahoo dot com Description: ------------ SimplyXML fails to load element attributes and values Tried with PHP 5.2.5 and 5.2.6, on Linux and Windows systems and got the same result. Reproduce code: --------------- <?php $xmlstr = <<<XML <?xml version="1.0"?> <test> <optgroup label="Non-Teen"> <option value="5">Under 5</option> <option value="9">Five to Ten</option> </optgroup> <optgroup label="Teen"> <option value="10">Aspiring Teen</option> <option value="15">Mid Teen</option> <option value="19">End Teen</option> </optgroup> </test> XML; $xml = new SimpleXMLElement($xmlstr); print_r ($xml); ?> Expected result: ---------------- The $xml array should have a SimpleXMLElement containing the "value" attribute for each "option" element Actual result: -------------- The "value" attributes of the "option" elements are not being loaded in the $xml array ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46137&edit=1

« previous php.bugs (#129153) next »