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

  • SEARCH
  • Home
  • 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 6653335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:15:24+00:00 2026-05-26T01:15:24+00:00

I am creating an application that requires the user to input two places (Postal

  • 0

I am creating an application that requires the user to input two places (Postal codes). My application will calculate the driving-distance between these two points ad output the result. The user has the option of adding Way-Points.
I think I would have to use the google maps API and get an xml file with the result and then parse the xml file. Can anyone help me because i not sure how to do this.
Appreciate all help.

Example…
Start: BR1 1LR

Waypoint: BR2 0LH

Waypoint: BR3 4AY

Destination: BR1 1LR

  • 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-05-26T01:15:24+00:00Added an answer on May 26, 2026 at 1:15 am

    I know this is really late, but I’m posting my solution to this in case anybody needs it.

    Firstly, i declared the URL (the one that calls google maps api)

    #define DST_API @"http://maps.googleapis.com/maps/api/distancematrix/xml?origins=%@&destinations=%@&units=%@&sensor=false"
    

    Next I created a string containing this URL:

    NSString *URL = [NSString stringWithFormat:DST_API, source, destination, units];
    

    Where source, destination are strings containing the start point and end point. units can be @”imperial” or @”metric”.
    Now that i had the URL, i would get back an xml string. To parse this, i used TBXML. There is always a large debate about which XML Parser to use. I used TBXML as it was easy, and is the fastest.

    TBXML *directionsParser = [[TBXML alloc] initWithURL:[NSURL URLWithString:URL]];
    
    // Check if the Overall status is OK
    TBXMLElement *root = directionsParser.rootXMLElement;
    TBXMLElement *element = [TBXML childElementNamed:@"status" parentElement:root]; 
    NSString *value = [TBXML textForElement:element];
    if ([value caseInsensitiveCompare:@"OK"] != NSOrderedSame) {
        [directionsParser release];
        return result;
    }
    

    Once checking the root status is OK, then obtain the result for the XPath expression: //row/element/distance/value

    element = [TBXML childElementNamed:@"row" parentElement:root];
    element = [TBXML childElementNamed:@"element" parentElement:element];
    element = [TBXML childElementNamed:@"status" parentElement:element];
    value = [TBXML textForElement:element];
    
    // Check if the Element status is OK
    if ([value caseInsensitiveCompare:@"OK"] != NSOrderedSame) {
            [directionsParser release];
        return result;
    }
    
    element = element->parentElement;
    
    element = [TBXML childElementNamed:@"distance" parentElement:element];
    
    //Note if you want the result as text, replace 'value' with 'text'
    element = [TBXML childElementNamed:@"value" parentElement:element];
    
    NSString *result = [TBXML textForElement:element];
    
    [directionsParser release];
    //Do what ever you want with result
    

    If anyone wants to have a URL to include way points, then here it is

    #define DIR_API @"http://maps.googleapis.com/maps/api/directions/xml?origin=%@&destination=%@&waypoints=%@&units=%@&sensor=false"
    

    But to use way points, things work a bit differently as Jano pointed out.

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

Sidebar

Related Questions

I am creating an application that requires a user to draw their hand signature
I'm creating a GUI application that requires the user to provide lots of numeric
I'm creating a gui application that requires some simple input, however, when I click
I'm creating an application that will store a hierarchical collection of items in an
I am creating an application that will have a list of items that can
I'm creating an application that will store geolocation data for specific transactions. Should I
I am creating a small application that will be deployed on Window. The database
I am creating an winform application that will run on a tablet PC. One
I'm creating a web application that will use multiple types of users (e.g. Admin,
We are creating a custom document management application that requires a viewer for the

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.