从excel文档查询以从活动XML数据源进行更新(我无法编辑或更改)。使用Excel查询在线XML文档
从网站的XML代码
<?xml version='1.0' encoding='utf-8'?>
<evec_api version="2.0" method="marketstat_xml">
<marketstat><type id="24692">
<buy><volume>58</volume><avg>187454397.24</avg><max>191102293.00</max><min>170620000.01</min><stddev>6655174.57</stddev><median>191000100.02</median><percentile>191102293.00</percentile></buy>
<sell><volume>66</volume><avg>211618794.64</avg><max>266968892.26</max><min>202896968.00</min><stddev>11782399.14</stddev><median>206970995.32</median><percentile>202896977.39</percentile></sell>
<all><volume>224</volume><avg>110889266.01</avg><max>266968892.26</max><min>0.99</min><stddev>30116759.19</stddev><median>186251523.01</median><percentile>0.99</percentile></all>
</type></marketstat>
</evec_api>
我的UDF的excel模块代码
Function GetPrice(sItemID As String, sItem As String, Optional sURL = "", Optional sSystem = "") As Variant
Dim oHttp As New MSXML2.XMLHTTP60
Dim xmlResp As MSXML2.DOMDocument60
Dim result As Variant
On Error GoTo EH
If sURL = "" Then
sURL = "http://api.eve-central.com/api/marketstat?typeid="
End If
If sSystem = "" Then
sSystem = "&usesystem=30000142"
End If
'open the request and send it
oHttp.Open "GET", sURL & sItemID & sSystem, False
oHttp.Send
'get the response as xml
Set xmlResp = oHttp.responseXML
' get Item
GetPrice = xmlResp.getElementsByTagName(sItem).Item(0).Text
' Examine output of these in the Immediate window
Debug.Print sName
Debug.Print xmlResp.XML
CleanUp:
On Error Resume Next
Set xmlResp = Nothing
Set oHttp = Nothing
Exit Function
EH:
GetPrice = CVErr(xlErrValue)
GoTo CleanUp
End Function
当试图查询=用getPrice(24692, “//卖出/分钟”)练成返回#值!错误。当查询= GetPrice(24692,“卖”)将返回66211618794.64266968892.26202896968.0011782399.14206970995.32202896977.39 这似乎是来自销售行的所有数据,当我正在寻找202896968.00与销售行数据标签下min以及buy标签中的最大值来填充Excel文档。