在cfquery中,解析的XML变量会发生变化吗? - Coldfusion和Bing

时间:2013-09-13 13:36:54

标签: xml coldfusion geocoding bing

这里真的很困惑。

我正在从Bing解析一个XML地理编码 - 我似乎正在变量。但是,当我在查询中使用该变量时 - 我没有得到变量的值 - 而是整个XML字符串?!

<cfset variables.BingXML = xmlparse(cfhttp.filecontent)> 

<cfset variable.Bing.Lat = "#variables.BingXML.Response.ResourceSets.ResourceSet.Resources.Location.Point.Latitude#">
<cfset variable.Bing.Lon = "#variables.BingXML.Response.ResourceSets.ResourceSet.Resources.Location.Point.Longitude#">
<cfoutput>
#variable.Bing.Lat# 
#variable.Bing.Lon#
</cfoutput>

这会返回正确的数字:

38.4935302734375
-101.35395050048828 

但在cfquery我得到了:

SELECT NATSS_Locations.*, NATSS_PaymentTypes.PTName, NATSS_PaymentTypes.PTImage, NATSS_PaymentTypeLinks.NPTLID,
   NATSS_NationalAccounts.NNAImage,  NATSS_NationalAccounts.NNAName, NATSS_LocNationalAcctLink.NLNALID,
   ((3963.191 * ACOS((SIN(PI() * '#variable.Bing.Lat#' / 180) * SIN(PI() * NATSS_Locations.LocationLat / 180)) + (COS(PI() * #variable.Bing.Lat# /180) * cos(PI() * NATSS_Locations.LocationLat / 180) * COS(PI() * NATSS_Locations.LocationLong / 180 - PI() * #variable.Bing.Lon# / 180)) )) * 1) as Distance 

变为:

SELECT NATSS_Locations.*, NATSS_PaymentTypes.PTName, NATSS_PaymentTypes.PTImage, NATSS_PaymentTypeLinks.NPTLID, 
    NATSS_NationalAccounts.NNAImage, NATSS_NationalAccounts.NNAName, NATSS_LocNationalAcctLink.NLNALID,
   ((3963.191 * ACOS((SIN(PI()     * '<?xml version="1.0" encoding="UTF-8"?><Latitude xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1">38.4935302734375</Latitude>' / 180) * SIN(PI() * NATSS_Locations.LocationLat / 180)) + (COS(PI() * <?xml version="1.0" encoding="UTF-8"?><Latitude xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1">38.4935302734375</Latitude> /180) * cos(PI() * NATSS_Locations.LocationLat / 180) * COS(PI() * NATSS_Locations.LocationLong / 180 - PI() * <?xml version="1.0" encoding="UTF-8"?><Longitude xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1">-101.35395050048828</Longitude> / 180)) )) * 1) as Distance

任何人都有解决方案或想法吗?

1 个答案:

答案 0 :(得分:2)

<cfset variable.Bing.Lat            
  = "#variables.BingXML.Response ... Point.Latitude#">
<cfset variable.Bing.Lon           
  = "#variables.BingXML.Response ... Point.Longitude#">

你应该有类似的东西:

 <cfset variable.Bing.Lat            
   = variables.BingXML.Response ... Point.Latitude.xmlText>
 <cfset variable.Bing.Lon            
   = variables.BingXML.Response ... Point.Longitude.xmlText>