-6

I want to get distance text from following link. i have used NSXML parsing but unable to get the result. please tell me which xml method should i used for following xml.

http://maps.googleapis.com/maps/api/directions/xml?origin=30.9165904,75.8634752&destination=30.89314000,75.86938000&sensor=true

Thanks to all

Sudha Tiwari
  • 2,499
  • 26
  • 50
  • 3
    It looks like fairly standard XML so any method you want will be fine. What have you tried so far? – Woody Jun 08 '12 at 11:07
  • i have used NSXML parsing but didnt get the result. – Sudha Tiwari Jun 08 '12 at 11:10
  • Why don't you share with us what you have tried (post some code snippet) and explain WHY it doesn't work ("it doesn't get the result" doesn't really tell us anything) and detail what you have tried to debug it and get it working. – Nick Bull Jun 08 '12 at 11:14

2 Answers2

0

Well the best is usually with the DOM, something like this:

var dist_element = document.getElementsByTagName("distance").child[1];

The thing there is, if you have several elements with the tag distance, you'll get an array. So you will need to iterate over every element.

Sorry I don't go over all the details, but exact implementation depends on your language of choice. Which language are you using?

David Cain
  • 16,484
  • 14
  • 65
  • 75
vicentito
  • 16
  • 2
0

i think use TouchXML for parsing...bellow link have answer for this

Parsing subnode with TouchXML

and also you can get subnode with its one example is bellow...

NSArray *nodes3 = [doc nodesForXPath:@"//step" error:nil];
//        NSLog(@">>>>>>>>>>>> response node count :%d", [nodes3 count]);

        for (CXMLElement *node in nodes3) { 

            NSString *str;
            for(int counter = 0; counter < [node childCount]; counter++) {  
//                NSLog(@">>>>>>>>> child node name :%@", [[node childAtIndex:counter] name]);

                if ([[[node childAtIndex:counter] name] isEqualToString:@"distance"]) {                 
                    str = [[node childAtIndex:counter] stringValue];
//                    NSLog(@"error number :%@", str);
                }
//etc....

            }
        } 

hope, this help you.. :)

Community
  • 1
  • 1
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70