note 95224 added to simplexml.examples

From: Date: Sat, 19 Dec 2009 20:49:24 +0000
Subject: note 95224 added to simplexml.examples
Groups: php.notes 
Request: Send a blank email to php-notes+get-164136@lists.php.net to get a copy of this message
When using simplexml to access a element the returned object may be a SimpleXMLElement instead of a string. Example: <? php $string = <<<XML <?xml version='1.0'?> <document> <cmd>login</cmd> <login>Richard</login> </document> XML; $xml = simplexml_load_string($string); print_r($xml); $login = $xml->login; print_r($login); $login = (string) $xml->login; print_r($login); ?> Expected result: ---------------- SimpleXMLElement Object ( [cmd] => login [login] => Richard ) Richard Richard Actual result: -------------- SimpleXMLElement Object ( [cmd] => login [login] => Richard ) SimpleXMLElement Object ( [0] => Richard ) Richard But this is an intended behavior. See http://bugs.php.net/bug.php?id=29500 ---- Server IP: 69.147.83.197 Probable Submitter: 200.116.2.86 ---- Manual Page -- http://www.php.net/manual/en/simplexml.examples.php Edit -- https://master.php.net/note/edit/95224 Del: integrated -- https://master.php.net/note/delete/95224/integrated Del: useless -- https://master.php.net/note/delete/95224/useless Del: bad code -- https://master.php.net/note/delete/95224/bad+code Del: spam -- https://master.php.net/note/delete/95224/spam Del: non-english -- https://master.php.net/note/delete/95224/non-english Del: in docs -- https://master.php.net/note/delete/95224/in+docs Del: other reasons-- https://master.php.net/note/delete/95224 Reject -- https://master.php.net/note/reject/95224 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#164136) next »