homepage Welcome to WebmasterWorld Guest from 54.227.5.234
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe and Support WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
Help with Google Maps xml output
crosescu




msg:3394963
 7:03 am on Jul 15, 2007 (gmt 0)

Hi,

I use PHP 5.0

I am trying to read the PostalCodeNumber node from the Google Maps xml output below:

$xmlstr = "<xml>
<Response>
<name>1600 amphitheatre mtn view ca</name>
<Status>
<code>200</code>
<request>geocode</request>
</Status>
<Placemark>
<address>
1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA
</address>
<AddressDetails Accuracy="8">
<Country>
<CountryNameCode>US</CountryNameCode>
<AdministrativeArea>
<AdministrativeAreaName>CA</AdministrativeAreaName>
<SubAdministrativeArea>
<SubAdministrativeAreaName>Santa Clara</SubAdministrativeAreaName>
<Locality>
<LocalityName>Mountain View</LocalityName>
<Thoroughfare>
<ThoroughfareName>1600 Amphitheatre Pkwy</ThoroughfareName>
</Thoroughfare>
<PostalCode>
<PostalCodeNumber>94043</PostalCodeNumber>
</PostalCode>
</Locality>
</SubAdministrativeArea>
</AdministrativeArea>
</Country>
</AddressDetails>
<Point>
<coordinates>-122.083739,37.423021,0</coordinates>
</Point>
</Placemark>
</Response>
</xml>"

$xml = new SimpleXMLElement($xmlstr);
$zipcode = $xml->AddressDetails->PostalCode->PostalCodeNumber;

for some reason it's not working. anyone got any ideas?

Thank you in advance for your help.

 

phranque




msg:3394981
 8:25 am on Jul 15, 2007 (gmt 0)

maybe something like this will work:

$zipcode = $xml->AddressDetails->Country->AdministrativeArea->SubAdministrativeArea->Locality->
PostalCode->PostalCodeNumber;

crosescu




msg:3395006
 9:56 am on Jul 15, 2007 (gmt 0)

the example of the xml output that is on the Google Maps API Documentation page is not correct.

I checked the xml output that I get back from Google and it does not contain the node "SubAdministrativeArea"

this gave me what i wanted $xml->Response->Placemark->AddressDetails->Country->AdministrativeArea->Locality->PostalCode->PostalCodeNumber

thank you for your help.

phranque




msg:3395386
 11:08 pm on Jul 15, 2007 (gmt 0)

and i just noticed i had missed the "Response->Placemark->" in my suggested solution based on their example...

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved