|
Mailing Lists
|
Home / Groups / ColdFusion Talk (CF-Talk)
Google Weather API XML Question: Getting the value of a nodeOn 20/03/2010 13:33, Chuck Weidler wrote: > > I have been trying to figure this one out for a while now. Running the below code will bring back a valid XML string and the XmlParse() is working just fine. The problem is trying to get the value for Condition in the<cfscript>. The error I'm getting is: Element XML_API_REPLY.WEATHER.CURRENT_CONDITIONS.CONDITION.XMLATTRIBUTES.DATA is undefined in XMLGOOGLE. > > I have tried every way I could thing of to address getting at the value, but with no luck. > > I would appreciate another set or two of eyes on this. try this: <cftry> <cfset urlAddress="http://www.google.com/ig/api?weather=21787"> <cfhttp url="#urladdress#" result="myResponse" /> <cfdump var="#myResponse.FileContent#"> <cfset xmlGoogle = XmlSearch(XmlParse(myResponse.FileContent),"/xml_api_reply/weather/current_conditions/condition")> <cfdump var="#xmlGoogle#" expand="no"> <cfscript> Condition = xmlGoogle[1].xmlAttributes.data; </cfscript> <cfoutput> <p>#Condition#</p> </cfoutput> <cfcatch type="any"> <cfdump var="#cfcatch#"> </cfcatch> </cftry> -- Yours, Kym Kovan mbcomms.net.au |
February 11, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||