views:

725

answers:

5

i am using gmail contacts api but the address is all in one string. is there any standard parser to parse a single string into a proper address object with the following fields:

Street Address 1
Street Address 2
City
State
Zip

+2  A: 

If you are getting this data from the google contact and you happen to be tapping into <gd.postalAddress> Take look at <gd:structuredPostalAddress> instead, where you won't have to parse since it will have the elements broken out for you already.

Though there were some bugs in it earlier this year, they may be worked out by now

curtisk
i am using the csharp client library and i dont see that structured PostalAddress
ooo
Per the docs at http://google-gdata.googlecode.com/svn/docs/index.html , StructuredPostalAddress is not in v1.4.02 of the .NET API. It is in Java, JavaScript, and Python APIs though.
Jeremy Seghi
+6  A: 

This SO thread addresses the same issue for Java -- but the selected answer is language agnostic, it just shows how to form a URL from the unstructured address and send it for parsing to Google Maps (with its wealth of information about city names, street names, etc).

This other SO thread has much more discussion and proposes many solutions, including one providing complete, stand-alone Visual Basic code.

Do you need help translating the VB (or other solutions) to C#?

Alex Martelli
no need for any language translation . .thanks for the links
ooo
@oo, you're welcome!
Alex Martelli
A: 

There is not a standard parser for addresses; You might look at the suggestions in this question: http://stackoverflow.com/questions/16413/parse-usable-street-address-city-state-zip-from-a-string but it seems US centric. There's also the recommendation of using the google maps API. This is actually very useful, but it's rate limited.

dlamblin
A: 

I suspect it depends very much on the class you are using and the configuration you use to call the api. Perhaps you could post an example of the string you receive. is it not xml or json already?

dice
A: 

Does anybody have an Idea, how to get the postaladdress detail information like ZIP, Street and City out of the API in VB or C# .NET?

Please help, I really would need a solution. Thank you! If someone has code for this issue, could you send me an email to [email protected]?

Ron