ID: 46137 Updated by: [EMAIL PROTECTED] Reported By: regsuy at yahoo dot com -Status: Open +Status: Bogus Bug Type: SimpleXML related Operating System: * PHP Version: 5.2.6 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php attributes are present although not always displayed by print_r Previous Comments: ------------------------------------------------------------------------ [2008-09-21 15:11:13] phpwnd at gmail dot com 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. ------------------------------------------------------------------------ [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