PHP looping trough XML error -


function loadfilestoarrays(){     $notpromo1array = simplexml_load_file('pages/hegnar/source/1/notpromo-1_08_04_2013_1.xml');         foreach($notpromo1array $xml){             echo $xml -> getname();             echo "<br>";             echo $xml -> ordrehode -> sluttkundenr;             echo "<br>";         } } 

my xml this

<?xml version="1.0" encoding="utf-8"?> <is_data> <ordrer class="linked-list">     <ordrehode>         <ordrekundenr>10541</ordrekundenr>         <sluttkundenr>1240</sluttkundenr>                     <and other properties></and other properties>..........     </ordrehode>     <ordrehode>         <ordrekundenr>10541</ordrekundenr>         <sluttkundenr>1344</sluttkundenr>                     <and other properties></and other properties>..........     </ordrehode>     <ordrehode>         etc etc etc ..................     </ordrehode> </ordrer> </is_data> 

and xml ended, etc, used notepad++'s xml validator.

i dont understand why when call loadfilestoarray function, error notice: trying property of non-object in /path/to/file/page1.php on line 104 is_data after enclosed in curly brackets , single quotes have seen lots of people referring when wanting echo data xml having special characters in property names in xml.

please give correct path of xml file right a.xml , test.php both in same folder

a.xml

<?xml version="1.0" encoding="utf-8"?> <is_data> <ordrer class="linked-list">     <ordrehode>         <ordrekundenr>10541</ordrekundenr>         <sluttkundenr>1240</sluttkundenr>                     <andotherproperties></andotherproperties>     </ordrehode>     <ordrehode>         <ordrekundenr>10541</ordrekundenr>         <sluttkundenr>1344</sluttkundenr>                     <andotherproperties></andotherproperties>     </ordrehode>     <ordrehode>         etc etc etc ..................     </ordrehode> </ordrer> </is_data> 

test.php

    <?php $notpromo1array = simplexml_load_file("a.xml"); foreach($notpromo1array $xml)   {     foreach($xml $child)     {         echo $child->getname();         echo "<br>";         echo $child->sluttkundenr;         echo "<br>";     }    }   /*result   * ordrehode     1240     ordrehode     1344     ordrehode   */  ?>  

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -