Page 1 of 1

simplexml & foreach error

Posted: Mon Mar 07, 2005 1:29 pm
by ddjen11
Hi I'm just learning simplexml, got a very basic question. Using the sample codes straight from php.net: http://us3.php.net/simplexml

In Example #3, it defines $xmlstr that hold a simple xml doc & loads it:

Code: Select all

$xml = simplexml_load_string($xmlstr);
Then it echoes some content:

Code: Select all

foreach ($xml->movie as $movie) {
echo $movie->plot, '<br />';
&#125;
"foreach" is causing an error that asked the browser to be closed. It happened on 2 different pcs on bothe IE & firefox. Can anyone point out the problem? Thanks for your help.


$xmlstr is set up this way(copied from the php link above):

Code: Select all

$xmlstr = <<<XML
<?xml version='1.0' standalone='yes'?>
<movies>
 <movie>
  <title>PHP: Behind the Parser</title>
  <characters>
   <character>
   <name>Ms. Coder</name>
   <actor>Onlivia Actora</actor>
   </character>
   <character>
   <name>Mr. Coder</name>
   <actor>El ActÓr</actor>
   </character>
  </characters>
  <plot>
   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.
  </plot>
  <rating type="thumbs">7</rating>
  <rating type="stars">5</rating>
 </movie>
</movies>
XML;
David


feyd | :roll:

Posted: Mon Mar 07, 2005 2:31 pm
by smpdawg
1. Please edit your existing post and use the code tags.

2. Is this test page somewhere that we can view it?

Posted: Mon Mar 07, 2005 3:02 pm
by timvw
do the usual debugging routine..

ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);


i tested the script with php5.0.3 and everythings works just fine.

Posted: Mon Mar 07, 2005 3:42 pm
by ddjen11
I am not even able to see any errors from php. I got a Windows message saying "Apache.exe has generated errors and will be closed by Windows. You need to restart the program. "

Windows2000 Professional

Apache Version Apache/2.0.52 (Win32) mod_ssl/2.0.52 OpenSSL/0.9.7e PHP/5.0.2

PHP Version 5.0.2

Simplexml support enabled
Revision $Revision: 1.139.2.4 $
Schema support enabled

Thanks.