Solved

Google and TSQL XML Readings

Posted on 2012-03-21
3
492 Views
Last Modified: 2013-11-19
Hello everyone,

I am currently working on getting geocoding information that may be obtained from google in xml using the following command:

http://maps.googleapis.com/maps/api/geocode/xml?address=3595+cadillac+ave,+costa+mesa,+ca&sensor=true

Open in new window


Is there a way to execute the line in above in TSQL and get the results back as follows: (so I can save that to a table)

<GeocodeResponse>
	<status>OK</status>
	<result>
		<type>street_address</type>
		<formatted_address>3595 Cadillac Ave, Costa Mesa, CA 92626, USA</formatted_address>
		<address_component>
			<long_name>3595</long_name>
			<short_name>3595</short_name>
			<type>street_number</type>
		</address_component>
		<address_component>
			<long_name>Cadillac Ave</long_name>
			<short_name>Cadillac Ave</short_name>
			<type>route</type>
		</address_component>
		<address_component>
			<long_name>Costa Mesa</long_name>
			<short_name>Costa Mesa</short_name>
			<type>locality</type>
			<type>political</type>
		</address_component>
		<address_component>
			<long_name>Orange</long_name>
			<short_name>Orange</short_name>
			<type>administrative_area_level_2</type>
			<type>political</type>
		</address_component>
		<address_component>
			<long_name>California</long_name>
			<short_name>CA</short_name>
			<type>administrative_area_level_1</type>
			<type>political</type>
		</address_component>
		<address_component>
			<long_name>United States</long_name>
			<short_name>US</short_name>
			<type>country</type>
			<type>political</type>
		</address_component>
		<address_component>
			<long_name>92626</long_name>
			<short_name>92626</short_name>
			<type>postal_code</type>
		</address_component>
		<geometry>
			<Location>
				<lat>33.7001816</lat>
				<lng>-117.9295300</lng>
			</Location>
			<Location_type>ROOFTOP</Location_type>
			<viewport>
				<southwest>
					<lat>33.6988326</lat>
					<lng>-117.9308790</lng>
				</southwest>
				<northeast>
					<lat>33.7015306</lat>
					<lng>-117.9281810</lng>
				</northeast>
			</viewport>
		</geometry>
	</result>
</GeocodeResponse>

Open in new window

0
Comment
Question by:John Esraelo
  • 2
3 Comments
 
LVL 39

Expert Comment

by:lcohan
Comment Utility
You could store it in a XML type data column or use XML SQL commands like FOR XML and OPENXML to read it in format you want.

http://msdn.microsoft.com/en-us/library/ms191268.aspx
0
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
Comment Utility
And you can run the http:// above in a SQL CLR stored proc since SQL 2005 and up - here's an example:

http://davidhayden.com/blog/dave/archive/2006/04/25/2924.aspx
0
 

Author Comment

by:John Esraelo
Comment Utility
Hi LCohan,
I have been reading the article and it is a very interesting piece.
Currently building the visual studio c# DLL.  Although, this example is for the city, state, county, I would like to see if I can alter this and add the street address as well.  After all, that is my project.

Going to discuss this with my boss and then take it from there today.
It looks like a promising code.
Will get back to you shortly.
thx

JohnE
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now