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

I am trying to get the distance between two places (across the roads) and I get that the HTTP request will return XML with the following data

http://code.google.com/apis/maps/documentation/directions/#XML

but I don’t understand how to use NSXMLParser to get the total distance. I suggest using

parser:didStartElement:namespaceURI:qualifiedName:attributes

but not sure how it works. The element that I need, I think, is the "direction", but there are a couple of such elements. How to specify which one I want? Is this related to the "attributes" parameter?

+3
source share
2 answers

NSXMLParser SAX, , . Google, , , , SAX.

DOM, NSXMLDocument, , , , Apple NSXMLDocument SDK iOS. , TouchXML.

, , XPath : //leg/step/distance/value. .

0

didStartElement , , foundCharacters ( ), didEndElement .

0

Source: https://habr.com/ru/post/1766599/


All Articles