simplexml & foreach error
Posted: Mon Mar 07, 2005 1:29 pm
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:
Then it echoes some content:
"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):
David
feyd |
In Example #3, it defines $xmlstr that hold a simple xml doc & loads it:
Code: Select all
$xml = simplexml_load_string($xmlstr);Code: Select all
foreach ($xml->movie as $movie) {
echo $movie->plot, '<br />';
}$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;feyd |