将eBay API XML导入Excel

时间:2017-08-06 10:11:30

标签: xml excel vba excel-vba ebay-api

我目前正在使用一小段XML来从eBay API导入数据。我的输出在API资源管理器上运行得很好 - 但我无法将其输入Excel(下面的XML)。

这是适用于API Explorer的XML,我试图提取:

<?xml version="1.0" encoding="utf-8"?>
<GetOrdersRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<!-- Call-specific Input Fields -->
<IncludeFinalValueFee>true</IncludeFinalValueFee>
<NumberOfDays>30</NumberOfDays>
<OrderRole>Seller</OrderRole>
<OrderStatus>Completed</OrderStatus>
<SortingOrder>Ascending</SortingOrder>
<!-- Standard Input Fields -->
<DetailLevel>ReturnSummary</DetailLevel>
<!-- ... more DetailLevel values allowed here ... -->
<ErrorLanguage>en_US</ErrorLanguage>
<MessageID>string</MessageID>
<!-- ... more OutputSelector values allowed here ... -->
<WarningLevel>Low</WarningLevel>
</GetOrdersRequest>

有没有人对更好的方法(或当前的修复方法)有任何建议或建议,以便将这些数据从eBay API中提取到Excel中?

我目前使用的方法如下。代码运行......但什么都不返回。我对VBA很缺乏经验(我通常使用记录宏功能...)但是即使在下面进行一些记录看看会发生什么也会有所帮助!

Sub GetSellerTransactions() 
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
URL = "https://api.ebay.com/ws/api.dll"
objHTTP.Open "POST", URL, False
objHTTP.setRequestHeader "X-EBAY-API-DEV-NAME", "________"
objHTTP.setRequestHeader "X-EBAY-API-CERT-NAME", "________"
objHTTP.setRequestHeader "X-EBAY-API-APP-NAME", "________"
objHTTP.setRequestHeader "X-EBAY-API-CALL-NAME", "GetSellerTransactions"
objHTTP.setRequestHeader "X-EBAY-API-SITEID", "0"
objHTTP.setRequestHeader "X-EBAY-API-REQUEST-Encoding", "XML"
objHTTP.setRequestHeader "X-EBAY-API-COMPATIBILITY-LEVEL", "967"

objHTTP.send (body)

Set objXML = New MSXML2.DOMDocument
objXML.LoadXML (objHTTP.ResponseText)

Dim xItemList As IXMLDOMNodeList
Set xItemList = objXML.SelectNodes("//Item")

Row = 1

Dim xItem As IXMLDOMNode
Dim copy As Worksheet

For Each xItem In xItemList
Cells(Row, 1) = xItem.SelectNodes("//Buyer/UserID").Item(0).Text
Cells(Row, 2) = xItem.SelectNodes("//Buyer/Name").Item(0).Text
Cells(Row, 3) = xItem.SelectNodes("///Buyer/Phone").Item(0).Text
Cells(Row, 4) = xItem.SelectNodes("//Buyer/Email").Item(0).Text
Row = Row + 1
Next

Set objHTTP = Nothing
Set objXML = Nothing

End Sub

0 个答案:

没有答案