View Single Post
Old 01-08-2009, 07:06 PM   #16 (permalink)
Dark Severance
The Visitor
 
Join Date: Jan 2009
Posts: 3
Thanks: 0
Dark Severance is on a distinguished road
Default

Unfortunately that doesn't work for me. So continuing to work with what he has done here I have...

I can then sort the xml data and have it display information in a table format (still work in progress) just by adding this to the code:
Code:
$armory = new armory('roster', 'Drenden', 'Priests of Discord', NULL, NULL);
$xml = $armory->pull_xml();

foreach ($xml->guildInfo->guild->members->character as $char) {
  echo "<tr id=\"".$char['name']."\">";
  echo "<td class=\"rightAlign\">".$char['name']."</td>";
  echo "<td>".$char['level']."</td>";
  echo "<td>".$char['class']."</td>";
  echo "<td>".$char['gender']."</td>";
  echo "<td>".$char['race']."</td>";
  echo "<td>".$char['achPoints']."</td>";
  echo "<td>".$char['url']."</td><br />";
  echo "</tr>";
			}
I understand that the following:
Code:
$armory = new armory('roster', 'Drenden', 'Priests of Discord', NULL, NULL);
$xml = $armory->pull_xml();
is broken up into variables that let me define where it's pulling the data. There are two different XML pages, one is 'roster' and the other is 'character'. The second field determines what server: 'Drenden'. The third field indicates the guild name: 'Priests of Discord'. The fourth field indicates specific character name: NULL. The last field is page number, when looking at guild information only used during the 'roster' option.

The problem is the 'character' xml page. There is a lot more information in that page. I could access it for a single character like 'Anastasia' by using the following code:
Code:
$armory = new armory('character', 'Drenden', 'Priests of Discord', 'Anastasia', NULL);
$xml = $armory->pull_xml();
I want to be able to temporarily load all the XML data for the 'roster' page as well as each 'character' page for only those members on that 'roster' page. I tried to do something like:

Load Armory Roster Page
Code:
$armory = new armory('roster', 'Drenden', 'Priests of Discord', NULL, NULL);
$xml = $armory->pull_xml();
Then use access the name variable to create a separate query for each by doing:
Code:
foreach ($xml->guildInfo->guild->members->character as $char) {
$armory = new armory('character', 'Drenden', 'Priests of Discord', $char.['name'], NULL);
$xml = $armory->pull_xml();
		}
Unfortunately that does not seem to work. I'm probably trying to load too much variable information or I have the wrong order of how I can use it. I might be over complicating it too. Step by step I can produce each thing individually, now I'm just trying to combine all the single steps so I can display it all on one page.



Full Code:
Code:
<?php

class armory {

 const BROWSER="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070319 Firefox/2.0.0.3";

 public $query;
 public $server;
 public $guild;
 public $guildie;
 public $page;

public function __construct ( $query, $server, $guild, $guildie, $page ) {
	$this->query = $query;
	$this->server = $server;
	$this->guild = $guild;
	$this->guildie = $guildie;
	$this->page = $page;
 } // end of __construct()

public function pull_xml() {

	// change the first part of the $url to the armory link that you need
	if( $this->query === 'roster' ){
		$url = 'http://www.wowarmory.com/guild-info.xml?r=' . urlencode($this->server) . '&n=' . urlencode($this->guild) . '&p=' . $this->page;
		
	  }elseif( $this->query === 'character' ){
		$url = 'http://www.wowarmory.com/character-sheet.xml?r=' . urlencode($this->server) . '&n=' . $this->guildie;
		
		}  

	$ch = curl_init();
	curl_setopt ($ch, CURLOPT_URL, $url);
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15);
	curl_setopt ($ch, CURLOPT_USERAGENT,  self::BROWSER);
	
	$url_string = curl_exec($ch);
	curl_close($ch);
	return simplexml_load_string($url_string);
	
   
 } // end of pull_xml()

} // end class  

$armory = new armory('roster', 'Drenden', 'Priests of Discord', NULL, NULL);
$xml = $armory->pull_xml();

	foreach ($xml->guildInfo->guild->members->character as $char) {
$armory = new armory('character', 'Drenden', 'Priests of Discord', $char['name'], NULL);
$xml = $armory->pull_xml();
		}

foreach ($xml->characterInfo->characterTab->professions->skill as $prof) {
	echo $prof['name'];
}

foreach ($xml->guildInfo->guild->members->character as $char) {
  echo "<tr id=\"".$char['name']."\">";
  echo "<td class=\"rightAlign\">".$char['name']."</td>";
  echo "<td>".$char['level']."</td>";
  echo "<td>".$char['class']."</td>";
  echo "<td>".$char['gender']."</td>";
  echo "<td>".$char['race']."</td>";
  echo "<td>".$char['achPoints']."</td>";
  echo "<td>".$char['url']."</td><br />";
  echo "</tr>";
			}

?>
Dark Severance is offline  
Reply With Quote