open All Channels
seplocked EVE Technology Lab
blankseplocked php/xml question
 
This thread is older than 90 days and has been locked due to inactivity.


 
Author Topic

InferiDiii
Caldari
Galactic Extensive Technologies
Posted - 2011.03.26 21:23:00 - [1]
 

Edited by: InferiDiii on 26/03/2011 22:03:11
Edited by: InferiDiii on 26/03/2011 22:01:49
I'm a nub with php and especially xml and was looking for some basic help. I'm just trying to get some simple info from the api and wasn't sure what the correct syntax is for this.

So with the server status from the xml results I can get the info I'm looking for (IE players and server time):

<?xml version='1.0' encoding='UTF-8'?>
<eveapi version="2">
<currentTime>2008-11-24 20:14:29</currentTime>
<result>
<serverOpen>True</serverOpen>
<onlinePlayers>38102</onlinePlayers>
</result>
<cachedUntil>2008-11-24 20:17:29</cachedUntil>
</eveapi>

I have this which works just fine.

$string = file_get_contents("http://api.eve-online.com/server/ServerStatus.xml.aspx");
$xml = new SimpleXMLElement($string);
print "(Players: ";
print($xml->result->onlinePlayers);
print ")(Server Time: ";
print($xml->currentTime);
print ")<BR><BR>";

Now with something like this:

<?xml version='1.0' encoding='UTF-8'?>
<eveapi version="2">
<currentTime>2010-10-05 20:28:55</currentTime>
<result>
<rowset name="Accounts" key="accountID" columns="accountID,accountKey,balance" />
<row accountID="4807144: accountKey="1000" balance="209127923.31"
</result>
<cachedUntil>2010-10-05 21:28:55</cachedUntil>
</eveapi>

I'm not sure how to set the equivalent of print($xml->result->onlinePlayers); from the first example to get info like balance. I'm pretty sure I'm missing something simple but couldn't really find anything in search or google (that made any sense to me anyway). Once I can get the output I can format it how I want just fine, I'm just missing extracting the data.

print_r($xml); will give me the following (though I'm not sure how to use it):

pleXMLElement Object ( [@attributes] => Array ( [version] => 2 ) [currentTime] => 2011-03-26 21:58:33 [result] => SimpleXMLElement Object ( [rowset] => SimpleXMLElement Object ( [@attributes] => Array ( [name] => accounts [key] => accountID [columns] => accountID,accountKey,balance ) [row] => SimpleXMLElement Object ( [@attributes] => Array ( [accountID] => 4807144 [accountKey] => 1000 [balance] => 209127923.31 ) ) ) ) [cachedUntil] => 2011-03-26 22:00:06 )
Any help would be appreciated. Thanks!

InferiDiii
Caldari
Galactic Extensive Technologies
Posted - 2011.03.26 22:12:00 - [2]
 

got it =/

print($xml->result->rowset[0]->row[0][balance]);


 

This thread is older than 90 days and has been locked due to inactivity.


 


The new forums are live

Please adjust your bookmarks to https://forums.eveonline.com

These forums are archived and read-only