Doc #61302 [Opn->Nab]: SimpleXML documentation has an error.

From: Date: Thu, 15 Mar 2012 02:01:07 +0000
Subject: Doc #61302 [Opn->Nab]: SimpleXML documentation has an error.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8067@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61302&edit=1 ID: 61302 Updated by: dtajchreber@php.net Reported by: timothy at green dot name Summary: SimpleXML documentation has an error. -Status: Open +Status: Not a bug Type: Documentation Problem Package: Documentation problem Operating System: Fedora Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: http://codepad.org/720OYnFR In short, echo $obj; that has a __toString method defined gives you a string. http://svn.php.net/viewvc/php/php-src/trunk/ext/simplexml/simplexml.c? revision=321634&view=markup#l1839 Previous Comments: ------------------------------------------------------------------------ [2012-03-06 17:13:09] timothy at green dot name Description: ------------ --- From manual page: http://www.php.net/simplexml.examples-basic --- The documentation reads: $movies = new SimpleXMLElement($xmlstr); echo $movies->movie[0]->plot; The above example will output: So, this language. It's like, a programming language. Or is it a scripting language? All is revealed in this thrilling horror spoof of a documentary. No. That example will not output that. It outputs a SimpleXML Object. You need to cast it to a string to get that output. The documentation should make this clearer. Test script: --------------- <?php header('Content-Type: text/plain'); $movies = file_get_contents('sample.movies.xml'); $xml = new SimpleXMLElement($movies); $plot = (string)$xml->movie->plot; var_dump($plot); foreach ($plot as $v) { var_dump($v); } exit(__FILE__ . ': ' . __LINE__); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61302&edit=1

« previous php.doc.bugs (#8067) next »