Solved

Google and TSQL XML Readings

Posted on 2012-03-21
3
495 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
ID: 37749784
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
ID: 37749802
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
ID: 37753047
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

770 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