• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Processing google weather XML file Information

Explorer ,
Oct 29, 2008 Oct 29, 2008

Copy link to clipboard

Copied

Google weather APi returns an XML file that I would like to process and store content into a database. You can view sample xml file by entering this in your browser .. http://www.google.com/ig/api?weather=chicago

How can I go about retrieveing the xml file and storing into a database ..This is wahat I have so far, let me know how to proceed since this does not work ..


<!--- Set the URL address. --->
<cfset urlAddress=" http://www.google.com/ig/api?weather=chicago">
<cfhttp url="#urladdress#" method="GET" resolveurl="Yes" throwOnError="Yes"/>


<cfset xmlDoc = XmlParse(CFHTTP.FileContent)><!--- THIS DOES NOT RETURN ANY CONTENT????. --->


<!--- Get the array of resource elements, the xmlChildren of the xmlroot. --->
<cfset resources=xmlDoc.xmlroot.xmlChildren>
<cfset numresources=ArrayLen(resources)>

<cfloop index="i" from="1" to="#numresources#">
<cfset item=resources >
<cfoutput>
<strong><a href=#item.url.xmltext#>#item.title.xmltext#</strong></a><br>
<strong>Author</strong>  #item.author.xmltext#<br>
<strong>Applies to these products</strong><br>
<cfloop index="i" from="4" to="#arraylen(item.xmlChildren)#">
#item.xmlChildren
.xmlAttributes.Name#<br>
</cfloop>
<br>
</cfoutput>
</cfloop>



TOPICS
Advanced techniques

Views

997

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2008 Oct 29, 2008

Copy link to clipboard

Copied

bemall wrote:
> <!--- Set the URL address. --->
> <cfset urlAddress=" http://www.google.com/ig/api?weather=chicago">
> <cfhttp url="#urladdress#" method="GET" resolveurl="Yes" throwOnError="Yes"/>
>
>
> <cfset xmlDoc = XmlParse(CFHTTP.FileContent)><!--- THIS DOES NOT RETURN ANY
> CONTENT????. --->


It does for me! Have you confirmed that the ColdFusion server can
access the URL.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 29, 2008 Oct 29, 2008

Copy link to clipboard

Copied

<!--- Set the URL address. --->
<cfset urlAddress=" http://www.google.com/ig/api?weather=chicago">
<cfhttp url="#urladdress#" method="GET" resolveurl="Yes" throwOnError="Yes"/>

<cfset xmlDoc = XmlParse(CFHTTP.FileContent)>
<cfoutput>#xmlDoc #</cfouput>

Does this return content for anyone elsse ??

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2008 Oct 29, 2008

Copy link to clipboard

Copied

bemall wrote:
> <!--- Set the URL address. --->
> <cfset urlAddress=" http://www.google.com/ig/api?weather=chicago">
> <cfhttp url="#urladdress#" method="GET" resolveurl="Yes" throwOnError="Yes"/>
>
> <cfset xmlDoc = XmlParse(CFHTTP.FileContent)>
> <cfoutput>#xmlDoc #</cfouput>
>
> Does this return content for anyone elsse ??
>

Put <cfoutput>#cfhttp.filecontent#</cfoutput> before the <cfset...> line
and see what is actually being returned from your request.

It might be an error message or some other content that is not XML formated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 29, 2008 Oct 29, 2008

Copy link to clipboard

Copied

This returns a blank as well ..
<!--- Set the URL address. --->
<cfset urlAddress=" http://www.google.com/ig/api?weather=chicago">
<cfhttp url="#urladdress#" method="GET" resolveurl="Yes" throwOnError="Yes"/>
<cfoutput>#cfhttp.filecontent#</cfoutput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2008 Oct 29, 2008

Copy link to clipboard

Copied

bemall wrote:
> This returns a blank as well ..
> <!--- Set the URL address. --->
> <cfset urlAddress=" http://www.google.com/ig/api?weather=chicago">
> <cfhttp url="#urladdress#" method="GET" resolveurl="Yes" throwOnError="Yes"/>
> <cfoutput>#cfhttp.filecontent#</cfoutput>
>

Then for some reason your server is not getting through to Google's
server of their response is not getting back to yours.

All I can say is it worked correctly and repeatedly so from mine.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 30, 2008 Oct 30, 2008

Copy link to clipboard

Copied

I am on a developement machine and using "localhost".
I can access the url fine from the browser and get the results on the browser. That verifies two way communcation to return xml results. Any other ideas

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 30, 2008 Oct 30, 2008

Copy link to clipboard

Copied

LATEST
bemall wrote:

> That verifies two way communication to return xml results. Any other ideas
>

That verifies that *you* have two way communication.

ColdFusion, even running on localhost, does not run as *you*, unless you
have told it to. By default it runs as 'localSystem' on Windows, on
Unix it will run under the user defined at install time.

It is quite possible for there to be cooperate domain policies that
allow you to access the internet, but not a generic 'localSystem' user.

One way to test this would be to configure the ColdFusion service|daemon
to run under your user name and password. Not an ideal, long term
solution, but a good test.

This makes a lot of assumptions about your details. This is a problem
with your system and your network connections. Those are the people you
are going to need to be working with to find out why this is not working.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation