How to parse distance data with iphone from google directions api? -


I am trying to get the distance between two places (the roadways), and I think that one Http will return an XML with the following data

But how do I use NSXMLParser to get total distance? I agree to use the

  parser: didStartElement: namespaceURI: qualifiedName: attributes  

method but it is not certain how it works I want that element to be "directions", but it has some couple elements How do I specify who I want? What to do with its "properties" parameter?

NSXMLParser is a SAX parser, and that means you have to callback methods When the document is processed, Google documents for various parsing events that you link to, I think these documents are not very large, and therefore I personally will not use SAX Parser.

A DOM parser, such as NSXMLDocument is very easy to use, but unfortunately Apple did not include NSXMLDocument in the iOS SDK. There are options, which include.

If you care only for total distance, and do not distance the distance of each stage or phase, then a simple XPath query will get all the distance for you: // foot / step / distance / Value . Loop through them and make them yoga.


Comments