Serenitee Posted August 25, 2009 Share Posted August 25, 2009 I found simplexml and have been working with it instead of writing my own parser and all is fine until this area: $count = count($file->characters->character); $i = "0"; while($i <= $count) {print $file->characters->character[$i]->attributes()->name; echo "<br>"; print $file->characters->character[$i]->id; echo "<br>"; print $file->characters->character[$i]->server; echo "<br>"; print $file->characters->character[$i]->class; echo "<br>";} specifically: print $file->characters->character[$i]->attributes()->name; Will return this error: Fatal error: Call to a member function attributes() on a non-object in C:\xampp\htdocs\penguin\xmlparse.php on line 110 If I change the $i to 0 (or 1, 2.. 77), ie: print $file->characters->character[16]->attributes()->name; it will return the name from that node (obviously for each instance). This is only occurring with the attributes areas, but my googlefu is not bringing anything up that explains it. Any thoughts? tia Link to comment https://forums.phpfreaks.com/topic/171826-solved-simplexml-while-loop-call-to-member-function-attribues-on-a-non-object/ Share on other sites More sharing options...
citricsquid Posted August 25, 2009 Share Posted August 25, 2009 uh, shouldn't $i = 0, not $i = "0"? Link to comment https://forums.phpfreaks.com/topic/171826-solved-simplexml-while-loop-call-to-member-function-attribues-on-a-non-object/#findComment-906026 Share on other sites More sharing options...
Serenitee Posted August 25, 2009 Author Share Posted August 25, 2009 LOL, I could kiss you if I weren't laughing so hard (and, well.. assuming you wouldn't freak out having a stranger kiss ya). Thank you! You rock for seeing that. Link to comment https://forums.phpfreaks.com/topic/171826-solved-simplexml-while-loop-call-to-member-function-attribues-on-a-non-object/#findComment-906050 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.