From:             zyxwvu at users dot sourceforge dot net
Operating system: Windows XP Pro
PHP version:      5CVS-2004-02-28 (dev)
PHP Bug Type:     *XML functions
Bug description:  SimpleXML - call to undefined method children()

Description:
------------
I've got this PHP code:



$xml = simplexml_load_file('file.xml');



foreach($xml-> children() as $name => $item){

  echo $name.'<br/>';

}



It was working with older PHP 5 snapshots (as I know, from January). But:
I have installed the newest PHP snapshot, and it returns:



Fatal error: Call to undefined method simplexml_element::children() in
myfile.php on line xxx



The same problem is with "xpath()" method. 

Reproduce code:
---------------
<?php

$xml = simplexml_load_string(

'<person>

 <child role="son">

  <child role="daughter"/>

 </child>

 <child role="daughter">

  <child role="son">

   <child role="son"/>

  </child>

 </child>

</person>');



foreach ($xml->children() as $second_gen) {

   echo ' The person begot a ' . $second_gen['role'];



   foreach ($second_gen->children() as $third_gen) {

       echo ' who begot a ' . $third_gen['role'] . ';';

   

       foreach ($third_gen->children() as $fourth_gen) {

           echo ' and that ' . $third_gen['role'] .

               ' begot a ' . $fourth_gen['role'];

       }

   }

}

?>

Expected result:
----------------
The person begot a son who begot a daughter; The person

begot a daughter who begot a son; and that son begot a son



Actual result:
--------------
Fatal error: Call to undefined method simplexml_element::children() in
file etc. etc.

-- 
Edit bug report at http://bugs.php.net/?id=27430&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27430&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27430&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27430&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27430&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27430&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27430&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27430&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27430&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27430&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27430&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27430&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27430&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27430&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27430&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27430&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27430&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27430&r=float

Reply via email to