ASP解析器选择特定的XML返回值 - FedEx Web服务

时间:2015-05-22 20:13:44

标签: xml asp-classic fedex

我正在尝试从FedEx Web服务费率回复(XML)中仅返回一个特定的费率集。 Rate Reply返回多个集合中的几种速率类型,我目前只能返回第一个集合。

这是抓取第一组结果的当前代码。

python -c 'import pdb, youtube_dl; print youtube_dl; pdb.runcall(youtube_dl.main, ["-h"])' youtube-dl

以下是费率请求的示例。我需要的数据是set xml = CreateObject("MSXML2.ServerXMLHTTP") xml.open "POST", "https://ws.fedex.com:443/web-services" xml.send soapEnvelope set parser = xml.responseXML set rates = CreateObject("Scripting.Dictionary") for each item in parser.SelectNodes("//RateReplyDetails") rates.add item.SelectSingleNode("ServiceType").text, item.SelectSingleNode("RatedShipmentDetails[0]").SelectSingleNode("ShipmentRateDetail").SelectSingleNode("TotalNetCharge").text next set GetFedExRates = rates 下的 TotalNetCharge

<v4:ActualRateType>PAYOR_LIST</v4:ActualRateType>

1 个答案:

答案 0 :(得分:0)

这是我使用here中的Rate Reply XML测试的一个简单示例。它应该提供有关如何在您的情况下实现它的指导。

set xml = CreateObject("MSXML2.DOMDocument")
xml.Load "fedex.xml"

set rates = CreateObject("Scripting.Dictionary")

for each item in xml.SelectNodes("//rate:RateReplyDetails")
    serviceType = item.SelectSingleNode("rate:ServiceType").text
    netCharge = item.SelectSingleNode("rate:RatedShipmentDetails/rate:ShipmentRateDetail/rate:TotalNetCharge/rate:Amount").text

    Wscript.Echo "ServiceType " & serviceType & vbCrlF
    Wscript.Echo "TotalNedCharge " & netCharge & vbCrlF

    rates.add serviceType, netCharge
next