View Single Post
Old 04-22-2009, 10:14 PM   #100 (permalink)
crispus
The Visitor
 
Join Date: Apr 2009
Posts: 3
Thanks: 2
crispus is on a distinguished road
Default

Quote:
Originally Posted by Krik View Post
The problem your having is fairly simple, if you have bit more knowledge in DOM (document object model) you would have seen it. Of course if I would have tested before giving it to you I would have seen it also.

The "$xml->guild->members->children()" isn't quite right the parent node of "guildInfo" was overlooked when I wrote that. So it should have been "$xml->guildInfo->guild->members->children()"

So all of it together would be
PHP Code:
<?php
$url 
'http://www.wowarmory.com/guild-info.xml?r=YOUR+SERVER=YOUR+GUILD&p=1';

$ch curl_init();
    
curl_setopt ($chCURLOPT_URL$url);
    
curl_setopt ($chCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt ($chCURLOPT_USERAGENT,  "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");

$rosterxml curl_exec($ch);  

$xml = new SimpleXMLElement($rosterxml);

foreach (
$xml->guildInfo->guild->members->children() as $char) {
    echo 
'<b>Name:</b> ' $char['name'] . ' ';
    echo 
'<b>Class:</b> ' $char['class'] . ' ';
    echo 
'<b>Level:</b> ' $char['level'] . ' <br>';

?>
I also took out the "echo $rosterxml;" as you don't need to echo the data twice.
I tried using the code that you've posted here, and I'm still experiencing the same "Fatal error: Call to a member function children() on a non-object in" error. Any ideas on what could be causing this? Thanks a lot in advance!
crispus is offline  
Reply With Quote