Jump to content

Recommended Posts

So I've been sitting here for a few hours trying to get what I considered an easy script working when I ran into a problem.  Currently I'm trying to pull XML information from the www.wowarmory.com website to make an updated roster on a website.  I've got the part where I pull the information from the armory fine, the problem I've ran into is making a DOMDocument and being able to use the information in it.  Here's the code I've got so far:

 

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.wowarmory.com/guild-info.xml?r=Gorgonnash&n=Midnight%20Reveries&p=1");
curl_setopt($ch, CURLOPT_HEADER, 0);
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"); 

$armory = curl_exec($ch);
curl_close($ch);
print_r($armory);

$doc = new DOMDocument();
$doc->loadXML($armory);

$memberList = $doc->getElementsByTagName("character");
foreach($memberList as $toon)
{
$data = array(
	'NAME' => $toon->getAttribute("name"),
	'RACE' => $toon->getAttribute("race"),
	'LEVEL' => $toon->getAttribute("level"),
	'CLASS' => $toon->getAttribute("class"),
	'GENDER' => $toon->getAttribute("gender"),
); 
echo $data['NAME'] . "<br/>";
}
?>

 

At this point I simply want it to list the name of each character attribute, but can't even get it to do that.  I'm not exactly sure what else to check.  Suggestions?  Errrors on my part? 

 

 

Thanks in advance :)

Link to comment
https://forums.phpfreaks.com/topic/153690-solved-domdocuments/
Share on other sites

Despite not receiving a reply, I did manage to finally figure out the problem

 

The problem wasn't in the code, it was correct, the problem was server side.  DOMDocuments are only supported in PHP 5 and by default, for some stupid reason, my service provider enables PHP 4... so after a few hours they finally managed to update my server to PHP 5 and everything's working how I want it and I'm finally able to move on with my script.

 

Hope it helps anyone else with future issues.

Link to comment
https://forums.phpfreaks.com/topic/153690-solved-domdocuments/#findComment-808389
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.