03-13-2009, 05:36 AM
|
#86 (permalink)
|
|
The Contributor
Join Date: Feb 2009
Posts: 65
Thanks: 0
|
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 ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_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.
|
|
|
|