USPS RateV4 - 如何显示费率对象?

时间:2013-09-30 07:26:57

标签: coldfusion usps

我在USPS Rate Calculator API使用以下代码:

<cfscript>
variables.RateV4 = variables.usps.RateV4(
                     Service = 'FIRST CLASS',
                     FirstClassMailType = 'LETTER',
                     ZipOrigination = '44106',
                     ZipDestination = '20770',
                     Pounds = '0',
                     Ounces = '3.5',
                     Size = 'Regular'
                   ); 
WriteDump(var="#variables.RateV4#" label="RateV4");
</cfscript>

输出类似于:

RateV4 - xml document [long version]
RateV4Response XmlText
           Package  xmltext 
                    .
                    '  
                    Postage  xmltext
                             .
                             .
                             Rate      xmlText 1.06 

Picture of the XML output

如何将速率对象变为简单的CF变量?即

<cfoutput>#RateV4.Package.Postage.rate.XmlText#</cfoutput>   

我尝试了一堆格式但没有成功。

1 个答案:

答案 0 :(得分:4)

查看转储中的顶级XML元素。

现在看看你在问题中发布的代码。

注意什么遗失?

您没有在代码中使用正确的XML“路径”(您在代码中省略了顶级节点)。

您还可以使用xmlSearch()来抓取rate节点。