These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

EVE API, Convert Google Sheets ImportXML to script [Help Needed]

First post
Author
lancemate
Caldari Provisions
Caldari State
#1 - 2014-11-08 15:22:29 UTC
Hi,

I am trying to convert the following xml import string to a script given the awful caching buggyness of the importxml function in Google sheets.

=ImportXML("http://api.eveonline.com/corp/StarbaseDetail.xml.aspx?keyID=xxxxx&vCode=xxxxx&itemID=xxxxx&","//row[@typeid=4247]/@quantity")

I would like itemID (tower ID) to be populated by the contents of another cell since I am already importing all our POS ID's with another script I found on this forum. I tried to adapt this script to get my intended result but I am failing miserably and only know JavaScript on a basic level. This is what I have come up with:

http://pastebin.com/DYZKF40X

It's failing pretty hard right now telling me it cannot call method getValue() of null.

I can see I am not parsing the fuel ID anywhere from the importXML command which I imagine is the problem, I have tried various ways of adding this to the code but to be honest I have no idea what I'm doing v0v.

Any help would be much appreciated.
Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#2 - 2014-11-08 18:30:44 UTC
I suspect the problem is you're using getChild, where you should be using getAttribute

Smile

try flipping the two getChilds for your tower=[] to getAttributes, and you should be good.


Explanation:
getChild is for use, when an XML tag contains another XML tag.
getAttribute is for use when you want to get at an attribute inside the tag declaration. like typeID='blah'


< row typeID="16273" quantity="4878" >< /row>

Is where you'd use getAttribute


< row>< typeID>16273< /typeID>< quantity>4878< /quantity>< /row>

if where you'd use getChild




aside from that, I'd also suggest parseInt(rows[i].getAttribute("quantity").getValue())
so that it shows up as a number, rather than as a bit

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

lancemate
Caldari Provisions
Caldari State
#3 - 2014-11-08 18:55:40 UTC  |  Edited by: lancemate
Thanks for taking the time to look at this.

I did try what you suggested but I still seem to be getting errors.

I think the problem may be in the importXML string I am specifically asking for a quantity where typeID matches 4247 (Amarr fuel block) wheras I just couldn't figure out how to get this into the script.

I created a new pastebin reflect your suggestions.
Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#4 - 2014-11-09 00:04:58 UTC
StarbaseList isn't the one you want.

StarbaseDetail is. I should have noticed that.

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

lancemate
Caldari Provisions
Caldari State
#5 - 2014-11-09 00:55:31 UTC
Steve Ronuken wrote:
StarbaseList isn't the one you want.

StarbaseDetail is. I should have noticed that.


Yep, I noticed about an hour ago also, I can't believe i spent all that time messing around with the script when my url was wrong :-)

Script has evolved a little with the help of a friend if you're interested: link it now pulls only the quantity where the fuelID is a specified ID which is more in line with what I needed.

My next question if you might know I'd be very grateful, I'm pulling my towerIDs etc from StarbaseList in another script, what is the easiest way to convert IDs such as typeID and locationID for example to in game names (tower type, system name.) I know about the static dump databases but I was kind of hoping there was an online resource I could cross reference?

thanks again.