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.
 

problem with quering xpath on eve api xml's

Author
vazelskyy
Deep Core Mining Inc.
Caldari State
#1 - 2011-11-11 20:41:33 UTC
Hi

I have a big problem with writing a corect xpath query

i hope some one from you can help me

I wat to put to my google docs document data form /corp/asetslist.xml

i wat to have info about what asets is in my working labs.

so i wrote an query for importXML function in google docs

=importxml("http://api.eveonline.com/corp/AssetList.xml.aspx?keyID="&H4&"&vCode="&H6&"","eveapi/result/rowset/row[@itemID="xxx"]/rowset/row//@typeID")

and in second column

=importxml("http://api.eveonline.com/corp/AssetList.xml.aspx?keyID="&H4&"&vCode="&H6&"","eveapi/result/rowset/row[@itemID="xxx"]/rowset/row//@quantity")

where xxx is the itemID of one of my labs

unfortynetly something is wrong with xpath query becouse i get prase error

i check my query on : http://www.xpathtester.com/test

and it works fine

can some one wyth more exp in Xprath can take a look on it ?

Thanks
Lutz Major
Austriae Est Imperare Orbi Universo
#2 - 2011-11-12 05:02:24 UTC
Without double checking, and I just woke up, of think its

/rowset/row//@quantity

must read

/rowset//row[@quantity]
vazelskyy
Deep Core Mining Inc.
Caldari State
#3 - 2011-11-12 06:47:00 UTC
xml file

ok this is the example file we are going to

the problem is that there are sub rows and we need to take elements only form them
Lutz Major
Austriae Est Imperare Orbi Universo
#4 - 2011-11-12 19:52:58 UTC
well, for me it worked:

eveapi/result/rowset/row[@itemID="xxx"]/rowset//row/@typeID

You must select each row, so //row not every attribute //@!
Max Kolonko
Caldari Provisions
Caldari State
#5 - 2011-11-14 00:02:56 UTC
Hi Vazelskyy, CCP screwed XML format, a lot of correct X-Path will not work
Lutz Major
Austriae Est Imperare Orbi Universo
#6 - 2011-11-14 04:56:18 UTC
Max Kolonko wrote:
Hi Vazelskyy, CCP screwed XML format, a lot of correct X-Path will not work

lolwut?
Jay Pava
Royal Amarr Institute
Amarr Empire
#7 - 2011-11-26 13:10:18 UTC
Im trying to bring up the skills list for various members in my corp. this is a project where we calculate the mineral yields from ores based on a member's refining skillsets, so it will be much easier to bring all this in from member's submitted API's, rather than having them update a spreadsheet manually with all their refining skills as/when they update them.

to do this, I am using the /char/CharacterSheet.xml.aspx function as this returns the whole list of a member's trained skills & levels. However, I need to have the "typeID's" and the "levels" in separate columns in order to do this properly. fine. I have read up on the API system and I think I can do that relatively easily. the trouble I am having is with referencing the names of the rowsets. for example, one rowset is called "skills", another "certificates", etc. Here is an extract from my own API data:

attributeEnhancers
attributes
rowset columns="typeID,skillpoints,level,published" key="typeID" name="skills"
row published="1" level="2" skillpoints="1415" typeID="3300"
row published="1" level="3" skillpoints="8000" typeID="3303"
row published="1" level="5" skillpoints="256000" typeID="3327"
row published="1" level="3" skillpoints="16000" typeID="3331"
row published="1" level="5" skillpoints="256000" typeID="3386"
row published="1" level="5" skillpoints="256000" typeID="3392"
row published="1" level="4" skillpoints="45255" typeID="3402"
row published="1" level="5" skillpoints="256000" typeID="3413"
row published="1" level="5" skillpoints="256000" typeID="3416"
row published="1" level="5" skillpoints="256000" typeID="3426"
row published="1" level="3" skillpoints="8000" typeID="3449"
row published="1" level="4" skillpoints="90510" typeID="3394"

what i need to get from all this data is a formula in google spreadsheets that lets me read the "skills" rowset, pull "typeID"'s into one column, and pull "level"'s into another column etc. if I can figure out the mechanics of this, putting together the rest of the spreadhseet will be straightforward. any help?
Dragonaire
Here there be Dragons
#8 - 2011-11-26 17:08:43 UTC
I'm guessing you know you'll need two different XPath queries to really do this but these should work or be close to what you need anyway.

eveapi/result/rowset[@name="skills"]/row/@typeID

eveapi/result/rowset[@name="skills"]/row/@level

The key part you were having problems with is selecting only the 'skills' rowset which is solved with the rowset[@name="skills"]

I haven't tested the XPaths but they should point you in the right direction anyway.

Finds camping stations from the inside much easier. Designer of Yapeal for the Eve API. Check out the Yapeal PHP API Library thread.

Jay Pava
Royal Amarr Institute
Amarr Empire
#9 - 2011-11-26 17:37:25 UTC
Indeed they have. I have a functioning import now. Thank you very much!
Ten Bulls
Sons of Olsagard
#10 - 2012-01-05 13:02:58 UTC  |  Edited by: Ten Bulls
Hi all, similar to the above posters, im trying to import the amount of material in a corp hanger into google docs.

All i know about XPath is what ive read on the forums... but i came up with the line below which works in xpathtester

"//eveapi/result/rowset/row[@itemID="1004508505967"]/rowset//row[@typeID="25857"]/@quantity"

Google docs reports a "Parse error", perhaps its because eveapi is not exactly the same as XPath (as a poster above mentioned), or im doing something else wrong, any ideas ?


Thanks


EDIT: I did try using // instead of / and removing some quoting, but im just guessing now...
Zhentar
Players vs. EVE
Goonswarm Federation
#11 - 2012-01-05 23:29:49 UTC
Just adding my request for some assistance onto the pile - I'm trying to do some google docs coding and it's proving rather complicated.

Is there a reason why some calls seem to work and some do not? For example, I'm looking at the corp/AccountBalance API, because it was simply the easiest one that I could see to start with. The following xpath works just fine for me:

"/eveapi/result/rowset//row/@balance"

And puts the 7 wallet balances in a vertical column. However, when I try to adjust it to add the accountKey as well, like this:

"/eveapi/result/rowset//row/@accountKey"

I get an error from google: the xPath query did not return any data.

Is there something else I need to be doing to get those accountKeys? And is there a better way to read in multiple columns of data from one API at the same time?



Any help would be greatly appreciated!
Jenn Makanen
Doomheim
#12 - 2012-01-06 01:44:48 UTC
Max Kolonko wrote:
Hi Vazelskyy, CCP screwed XML format, a lot of correct X-Path will not work


Umm, I have to say... Bullshit. Just to make sure that no-one reads your comment and thinks you have a clue what you're talking about.

It's perfectly valid XML. All the tags are either atomic (with a / at the end) or properly closed. Sure it'd be nice to have a published DTD or schema to work with, but they're not a requirement.

Is it, perhaps, possible that you don't properly understand X-Path, and are trying to access nodes, where you should be accessing attributes?

Using /eveapi/result/rowset/row/orderID where you should be using /eveapi/result/rowset/row/@orderID


I'm not expecting a response, but if you are going to give one, show us some of this correct xpath syntax that's not working.
Jenn Makanen
Doomheim
#13 - 2012-01-06 02:00:32 UTC
Ten Bulls wrote:
Hi all, similar to the above posters, im trying to import the amount of material in a corp hanger into google docs.

All i know about XPath is what ive read on the forums... but i came up with the line below which works in xpathtester

"//eveapi/result/rowset/row[@itemID="1004508505967"]/rowset//row[@typeID="25857"]/@quantity"

Google docs reports a "Parse error", perhaps its because eveapi is not exactly the same as XPath (as a poster above mentioned), or im doing something else wrong, any ideas ?


Thanks


EDIT: I did try using // instead of / and removing some quoting, but im just guessing now...



For your elucidation, // is a wildcard match, / is a exact path. basically // means 'I don't care what the path is up to this point. give me everything that otherwise matches. Powerful, but to be used sparingly, as it might lead to unintended side effects.



I'm not entirely sure what the problem is for google docs though. Playing with Perl's xpath tool, and the xml from http://wiki.eveonline.com/en/wiki/EVE_API_Corporation_Asset_List

/eveapi/result/rowset/row[@itemID=1000474513775]/rowset/row[@typeID=255]/@quantity

should work. It's pulling back the right values, certainly (I added another node to the XML to try it.)

I'm not seeing anything obviously wrong with yours (other than extraneous //s). I'd suggest trying something a lot simpler, and making sure you are actually getting the data you expect in google docs, in case there's a problem there. Eve's xml is well formed, so there's not incompatibility with XPath,
Jenn Makanen
Doomheim
#14 - 2012-01-06 02:10:06 UTC  |  Edited by: Jenn Makanen
Zhentar wrote:
Just adding my request for some assistance onto the pile - I'm trying to do some google docs coding and it's proving rather complicated.

Is there a reason why some calls seem to work and some do not? For example, I'm looking at the corp/AccountBalance API, because it was simply the easiest one that I could see to start with. The following xpath works just fine for me:

"/eveapi/result/rowset//row/@balance"

And puts the 7 wallet balances in a vertical column. However, when I try to adjust it to add the accountKey as well, like this:

"/eveapi/result/rowset//row/@accountKey"

I get an error from google: the xPath query did not return any data.

Is there something else I need to be doing to get those accountKeys? And is there a better way to read in multiple columns of data from one API at the same time?



Any help would be greatly appreciated!



Odd. The xpath works absolutely fine for me. Sounds like google's playing up with it's xpath parsing. Have you tried it with a lowercase K? Have you tried /just/ getting the key, and not the balance? (In case It's doing something funny like hitting the api again, and making it complain about the rate of access?)

edit: I did find http://www.eveonline.com/ingameboard.asp?a=topic&threadID=1566854&page=1#4, which mentions that googledoc's xpath engine lowercases everything. Though why it works for typeID, I'm not sure.
Zhentar
Players vs. EVE
Goonswarm Federation
#15 - 2012-01-06 02:27:00 UTC  |  Edited by: Zhentar
I've just tried that now, with no success. It seems rather spotty, however - sometimes the error I get is 'Data temporarily unavailable', sometimes its 'The xPath query did not return any data'

Is there a better way to do this? Any way of simply downloading one entire API call with every column/row, and then I can go through and manually delete the pieces I don't need?

Edit: And it worked, with lowercase k, the second or third time. Very strange. Still having trouble with other keys, but it seems like it may just be completely random.
Jenn Makanen
Doomheim
#16 - 2012-01-06 02:32:44 UTC
To be honest, I'm really not sure.

I just tried playing with
=importXML("https://api.eveonline.com/eve/CharacterID.xml.aspx?names=Jenn%20Makanen","//row/@characterID")
Which doesn't work. However
=importXML("https://api.eveonline.com/eve/CharacterID.xml.aspx?names=Jenn%20Makanen","//row/@characterid")
does work

So googledocs are messing with the cases, and appear to be lower casing all the attribute names. But /not/ lowercasing attribute names in xpath. Just to confuse matters.

On trying it with the corp account balance, it works with /eveapi/result/rowset/row/@accountkey, and not with /eveapi/result/rowset/row/@accountKey

Ten Bulls
Sons of Olsagard
#17 - 2012-01-06 02:50:02 UTC  |  Edited by: Ten Bulls
Jenn Makanen wrote:
To be honest, I'm really not sure.
So googledocs are messing with the cases, and appear to be lower casing all the attribute names. But /not/ lowercasing attribute names in xpath. Just to confuse matters.


WOOT, i just took the capitals out of my path and it works !

"//eveapi/result/rowset/row[@itemid=1004508505967]/rowset/row[@typeid=20172]/@quantity")

I changed itemID to itemid and typeID to typeid
Glarbl Blarbl
Orion-Glarbl Mining Bureau
#18 - 2012-03-09 23:10:17 UTC
Very helpful thread!


However, I'm still kind of confused... I was able to get my corp market orders to display w this:
=IMPORTXML("https://api.eveonline.com/corp/MarketOrders.xml.aspx?vcode="&{CorpVcode}&"&keyid="&{CorpID}&"","/eveapi/result/rowset/row/@orderid")

So i know my named ranges are translating correctly (CorpVcode, etc), and I think I have a handle on the syntax now... But then why doesn't this work?
=IMPORTXML("https://api.eveonline.com/corp/WalletTransactions.xml.aspx?vcode="&{CorpVcode}&"&keyid="&{CorpID}&"","/eveapi/currentTime/result/rowset/row/@transactionid")

I pared it down to just the currentTime to make sure that string is supposed to have mixed case (it worked), but when I tried to expand it to get the data I want it won't show... currentTime is a parent to results, right? (it doesn't work w it or w/o it -- also tried //result/rowset/row/@transactionid and just //@transactionid w no luck)

For a second I thought it might be that the wallet transactions API doesn't accept Corp Vcode/IDs since they aren't listed on the API info page, but it appears to be the same w the market orders and they worked there.

So I'm stumped, any fresh eyes see an obvious error I have made?

Thanks!
GB