Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7883247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:28:58+00:00 2026-06-03T04:28:58+00:00

I am using the Google Geocoding API, specifically relying on the XML output format.

  • 0

I am using the Google Geocoding API, specifically relying on the XML output format. The code below loops through the array $arrGeocodeSales and for each row it retrieves the $lat and $long, which are then displayed in the table.

This code is working fine, but I would like to extend it so that I can extract more fields from the $xml result that is returned. For example, some of the additional fields that I would like to extract from the $xml result are formatted_address and postal_code. How can I modify the code below to extract the additional fields?

You can see an example of an $xml result here:

http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true

Here is the code that needs to be modified. I guess I don’t understand how to work with the SimpleXMLElement that is returned. Thanks for the help.

<table border="1" style="margin-bottom:0px;">
<tr>
  <th>ID</th>
  <th>Roll</th>
  <th>Address</th>
  <th>Lat</th>
  <th>Long</th>
  <th>MapSaleNumber</th>
  </tr>

<?php foreach ($arrGeocodeSales as $key => $value): 
    $address = $value['Address']."+".$value['Municipality']."+Ontario+Canada"; 
    $googleAddress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml";
    // Retrieve the URL contents
    $googlePage = file_get_contents($googleAddress);
    // Parse the returned XML file
    $xml = new SimpleXMLElement($googlePage);
    // Parse the coordinate string  
    list($lng, $lat, $alt) = explode(",", $xml->Response->Placemark->Point->coordinates);
 ?>
<tr>
  <td ><?php echo str_pad($row++, 2, '0', STR_PAD_LEFT); ?></td>
  <td ><?php echo $value['SingleRoll']; ?></td>
  <td ><?php echo $address; ?> </td>
  <td ><?php echo $lat ?></td>
  <td ><?php echo $lng ?></td>
  <td ><?php echo $value['MapSaleNumber']; ?></td>
  </tr>
<?php endforeach; ?>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:28:59+00:00Added an answer on June 3, 2026 at 4:28 am

    You can manipulate the SimpleXMLElement result using the methods documented here.

    You will need to iterate through the address_component elements to find one with the type element value you are interested in. Look for examples of other code using that API and you should be able to quickly figure it out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using http://code.google.com/apis/maps/documentation/geocoding/ api from google to get geolocation based on address. I
I am currently using the google maps' reverse geocoding API to convert long/lat received
Using V3 of the google maps API, is there any reliable way to format
I've seen many posts about the Google Geocoding API, described here: http://code.google.com/apis/maps/documentation/geocoding/ but none
I'm doing some geocoding using the google maps API. The user fill a form
I am trying to do some basic geocoding using the google maps API and
I am using the Google Geocoding API v3[1] from an iOS application but can't
We are using the Google Maps API method getLocations() for geocoding addresses the user
I am using google maps Api V3 and using reverse geocoding to find the
Could someone advise on the quota limits to Google maps geocoding api? I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.